Saturday, June 30, 2018

Inheritance

Inheritance is a concept where one class can inherit all the methods and variables
from another class. A child class inherits the methods of the parent class.
Additional methods can be applied to the child class, and inherited methods can
be overridden. This means the child class is not always identical to the parent
class.
The advantage of inheritance in object-oriented programming is that code can be
written one time and be reused many times.


NOTE: In X++ one class can extend another class, and one extended data type
can extend another.
Extend a ClassTo have a class extend another class, modify the classDeclaration code of the
child class by adding extends and then the parent class, shown as follows:
class Child extends Parent
{
}

Objects created from the ChildHave at least the same methods and variables as the Parent.Can have methods and variables that do not exist in the Parent.Can have methods from the Parent that are overridden or altered, in
the Child.
For example, if the Parent contains four methods:
Method1, Method2, Method3, Method4the Child can have two of those methods overridden, plus an additional method.Method1, Method3, Method5If the code refers to one of the methods in the Child that has not been overridden,
the system will go to the Parent to retrieve the method. If that method then calls a
method that is in the Child, it will revert back to the Child.

Best Regards,
Hossein Karimi

No comments:

Post a Comment

Configure the Firewall on the Enterprise Portal Server

After you install Enterprise Portal, enable Web Server (HTTP) in Windows Firewall. If you do not enable the web server in Windows Firewall...