Tuesday, June 23, 2009

Inheritance and the Component Namespace

A subclass contains all components of all its superclasses. Only the public and the protected components are visible. This is why all public and protected components of an inheritance tree lie within a single namespace and must have unique names. Private components, in contrast, must only be named uniquely within a class.

When methods are redefined, the newly implemented method hides the identically named method of the superclass. As soon as the method is redefined, it replaces the old method to ensure that the name remains unique. The pseudo reference super-> can be used in subclasses to access a method of the direct superclass which is hidden as a result of a redefinition.

No comments:

Blog Archive