previous | index | next

Overriding the display Method

ItemInfo only has limited information about an Oxford shirt.

OxfordShirtInfo should override display to make it more specific to shirts:

  The item's price is 49.99
  The item's color is Navy blue
  The item's neck size is 15
  The item's sleeve length is 33
However, it should make use of what ItemInfo can do to avoid repetitive code.

To get at a superclass method from within a subclass method of the same name, use the scope resolution operator "::".

In our example: ItemInfo::display.

The scope resolution operator disambiguates names that are reused within classes.


previous | index | next