Question about inheritance

Noel Yap nyap@garban.com
Tue Aug 4 12:31:00 GMT 1998


Alexandre Oliva wrote:
> 
Peter V Evans <pevans@enteract.com> writes:
> a better question would be, how to get doit to somehow see the
> derived class "hi" instead of the parent class "hi"?

I missed this the first time.  You would *never* want a superclass to
know about subclasses.  Dependencies should *always* go from the
subclass to the superclass.  If any of your dependencies go the other
way, then all your subclasses wind up depending on that one subclass. 
This breaks one of the biggest tenets of OO -- localisation of effects
due to changes in code.  IOW, it causes major headaches for testing and
enhancements.

Noel



More information about the Gcc mailing list