I was explaining OOP to my friend. I was unable to answer this question. (How shameful of me? :( )
I just escaped by saying, since OOP depicts the real world. In rea
I think you mean:
Child aChild = aParent;
You did not specify that aChild
is of type Child
.
The reference to a Child
type will mean that you can call members on it that may no exist in the Parent
. So, if you assign a Parent
object to a Child
reference, you will be able to call members that do not exist on the Parent
.