Interesting... I did not know that Actionscript used the word "parent" in that way.
There are two separate concepts at work here: inheritance and composition. The term parent
is used in both cases in Objective-C and many other object-oriented languages.
In Objective-C, a class which inherits from another refers to that "other" class as its ancestor. While many people use the term superclass
, in fact you could quite legitimately use the word parent
. As the names imply, this is object "inheritance".
Object "composition", on the other hand, is what you've described with the example of the car and wheel. A car is composed of several other objects, one or more of which is the wheel. I must admit, I've not often heard the term parent
used in this context to refer to the car. Usually, you'll probably find most people in the Objective-C world would recognize the car
by the label "container". In the case of a tree-style data structure like an XML document, though, we often talk about parent nodes and child nodes. The parent contains the children, so using the word "parent" in a composition relationship is also apposite depending on the type of relationship. I don't think you'll find many Objective-C programmers using the "parent" word in composition scenarios outside of a tree structure, though.
The distinction is often likened to a "has a" versus "is a" relationship: identity versus possession. In inheritance, the child "is a" subtype of its parent. In composition, on the other hand, the car "has a" wheel, or a parent node in a tree "has a" collection of child nodes.
Edit: Kendall Helmstetter-Gelner below added some good comments on the part of your question related to instances and passing references. If you have a particular block of code and a specific error message, please feel free to update your question with them and we'll try to help.