previous | index | next

Calling Superclass Constructors

A superclass constructor can be called from a subclass constructor like this:
    OxfordShirtInfo(double p, string c, int n, int s):
      ItemInfo(p, c) { ... body of constructor ... }
The full class:

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; }
private:
  int neck;
  int sleeve;
};


previous | index | next