Implicit casting from super-class to sub-class
X++ compiler allows casting from the super-class object to the sub-class. For example, UserConnection class extends Connection class. And you are allowed to write the following code:
UserConnection con = new Connection();
The only consequence of doing such thing is a run-time error thrown if a method that exists only on sub-class will be called for the instantiated object.
In the modern managed languages such implicit casting is not allowed and generates compilation error. So, it is best practice not to use it in AX too.
UserConnection con = new Connection();
The only consequence of doing such thing is a run-time error thrown if a method that exists only on sub-class will be called for the instantiated object.
In the modern managed languages such implicit casting is not allowed and generates compilation error. So, it is best practice not to use it in AX too.
This was originally posted here.
*This post is locked for comments