Inheritance allows you to use code from an existing class in your project as a starting point to build a more specific class for the project. An object of the child class can directly access any unique attributes you define for the class. The child class also gains access to the protected VIs on the Member List of the existing class. To access the fields of a parent class, an object of the inheriting child class can use members from the parent class that have direct access to the fields.
Inheritance in G Dataflow follows a hierarchy of parent and child classes.
- G Object—Object that defines classes. The G object is the top of the class hierarchy. Every class inherits from the G object.
- Ancestor Class—Class from which the parent class inherits and therefore a child class indirectly inherits.
- Parent Class—Class that provides fields and methods for another class to use. A parent class can provide inheritance to more than one child class in your project.
- Child Class—Class that inherits access to certain methods of a parent class. A child class can extend or override the functionality of the methods it inherits to fit its own requirements. It can also include additional fields that apply only to the child class. A child class can inherit from only one parent class directly though it can inherit indirectly from many ancestor classes.
- Sibling Class—Child classes that inherit from the same parent class.
You can plan and track the inheritance relationships in your project with an inheritance hierarchy illustration. An inheritance hierarchy displays all of the classes in your project and the inheritance relationships between them. The class at the top of the hierarchy provides inheritance for all other classes in the hierarchy. Each arrow in the hierarchy points to a child class that inherits from a parent class.
The following illustration shows the inheritance of fields and member VIs throughout a hierarchy of generic classes.
Once you create your project, you can check the actual flow of inheritance against your plan using the Class Hierarchy Viewer.