Forum Discussion

dev42's avatar
dev42
Visitor
11 years ago

OOP: access parent obj & Inheritance

I submitted my first app! It needs a lot more love, but I had to pass this milestone.

So, in order to improve the refactoring / code (re)design, I'm looking for ways for 2 child objects to be able to communicate with each other. On top of that, is there a built in feature where the child can know what the parent knows?

My prior way of solving this was to pass the parent's "m" to the function. ( I don't have my code with me at the moment so my memory is a bit fuzzy. Edit: and I did go with GetGlobalAA() on a few things. ) I'd give this argument the name: "mm" in the function . That way I could access whatever it was I needed.

Well, now I'm considering a different approach. Instead of passing in the parent's "m", why not have an attribute called... wait for it... and I hope you aren't lactose intolerant because it is going to be legen-Dairy... "parent"? *rim-shot*

So, each child will now have a pointer that points to the parent object. Easy peesy.

If there is some sort of inheritance that I've missed or someway to know how to get at data all child object should know about their parent (obj), please let me know!

peace & 42
No RepliesBe the first to reply