previous | index | next

Overriding the display Method

class OxfordShirtInfo: public ItemInfo {
public:
  OxfordShirtInfo(double p, string c, int n, int s):
    ItemInfo(p, c) {
    neck = n;
    sleeve = s;
  }
  int getNeck() { return neck; }
  int getSleeve() { return sleeve; }
    
  void display() {
    ItemInfo::display();
    cout << "The item's neck size is " << neck << endl;
    cout << "The item's sleeve length is " << sleeve << endl;
  }
private:
  int neck;
  int sleeve;
};
Note that a definition of the ChinoInfo class would be analogous to this.

previous | index | next