LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Child classes vs. instatiated classes

Solved!
Go to solution

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.

0 Kudos
Message 1 of 5
(878 Views)

Child class is another class that inherits from the parent class like how a kid inherits from parents.

 

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 2 of 5
(867 Views)

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).

Message 3 of 5
(860 Views)

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.

0 Kudos
Message 4 of 5
(828 Views)
Solution
Accepted by topic author skinnedknuckles

@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:

wiebeCARYA_0-1660819856990.png

 

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...

0 Kudos
Message 5 of 5
(817 Views)