01-27-2011 12:04 PM
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
Solved! Go to Solution.
01-30-2011 09:26 AM
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.
01-31-2011 08:43 AM
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.