Inheritance in x++

 What is Inheritance in x++?

answer: 

Inheritance is a concept where child class (derived class) can inherit all the methods and variablesfrom parent class(base class).


Rules:

-> A class can extend only one other class.

-> Multiple inheritance isn't supported.

-> If we extend a class, the subclass (derived class) inherits all the methods and variables in the parent class (the superclass).

-> Subclasses let us reuse existing code for a more specific purpose.

-> A superclass is often known as a base class, and a subclass is often known as a derived class.


How to prevent the inheritance?

ans:

We can prevent classes from being inherited by using the final modifier.

Example:

public final class Attribute

{

    int objectField;

}

Comments

Popular posts from this blog

how to post trade agreement journals automatically using x++ code

How to Create a wizard in x++ d365

x++ code to submit and approve and reject the invent movement workflow in d365 F&O