08-17-2022 08:14 PM
Is a child class just another name for an instance of the parent class? I guess I'm unclear about how to setup and use an instance of a simple class and how to do the same for a class that inherits from some other class.
Solved! Go to Solution.
08-17-2022 08:46 PM
Child class is another class that inherits from the parent class like how a kid inherits from parents.
08-17-2022 09:06 PM
In addition to the other reply, you think of class as a template and object as an instance of that template. Thus parent objects are instances of the parent class. Child objects are instances of the child class, which contain both the child private data (which needs methods in order to access) and the parent private data (which needs methods of the parent class to access).
When you create a new instance of a class (by dropping its class constant on a block diagram) you get the default value of it's private fields (including the private fields of any parent classes).
08-18-2022 03:48 AM
A class is something which describes the parameters and methods of your code.
When you actually instantiate this in code at run-time, it is an Object.
When you define one class to inherit from another object to add methods or alter behaviour, that new class is a child of the first.
When that child class is instantiated (actually created to run-time) it is also an Object, but of type Child.
08-18-2022 05:52 AM
@skinnedknuckles wrote:
Is a child class just another name for an instance of the parent class?
Just to be clear: NO.
@skinnedknuckles wrote:
how to setup and use an instance of a simple class and how to do the same for a class that inherits from some other class.
An instance of a class (both simple and complex) is a matter of using a constant (or control) on your diagram:
An instance of a child class is exactly the same...
A child class can be made by making a class, and changing it's inheritance to the parent class.
I think you would benefit form doing a tutorial or two...