LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

OOP question involving inheritance

Solved!
Go to solution

Hello,

 

I am trying to build an application using OOP, which I am new to, and have a problem. The attached zip file has some dummy code which when run will show the problem, in the stop case. I seem to be able to add classes to a parent, but the parent data is being overwritten apparently.

 

Tay

0 Kudos
Message 1 of 3
(2,241 Views)
Solution
Accepted by topic author slipstick

There is one issue in your code.

Every time you change a state, you take an NEW object. The new object don't know anything about what you have done in a state before.

Therefor it seems that the parents data is overwritten, but that is not the case. You are overwriting the hole objact with a new fresh object, which parent dot have any data.

 

It is each object that remembers its own data, also what its parent can have, no matter if different classes have the same parent.

The parent - child relation is not a way to share data between objects. it is a way to define a class with commen methods for different classes.

Message 2 of 3
(2,205 Views)

Thanks for the reply. I had sort of figured that out from another example I found by Googling for code images. All is fine now.

0 Kudos
Message 3 of 3
(2,182 Views)