I'm self studying from the book, C++ Primer Plus Fifth Edition, by Stephen Prata. The following relates to Chapter 13, Page 699, Programming Exercise #4. One task is to write the derived class method definitions based upon the given prototypes. The following are the said prototypes.
class Port
{
private:
char *brand;
char style[20]; // i.e. tawny, ruby, vintage
int bottles;
public:
Port(const char *br = "none", const char *st = "none", int b = 0);
Port(const Port &p); // copy constructor
virtual ~Port() { delete [] brand;}
Port & operator=(const Port &p);
Port & operator+=(int b);
Port & operator-=(int b);
int BottleCount() const {return bottles;}
virtual void Show() const;
friend ostream &operator<<(ostream &os, const Port &p);
};
class VintagePort : public Port
{
private:
char * nickname; // i.e. The Noble, or Old Velvet, etc.
int year; // vintage year
public:
VintagePort();
VintagePort(const char *br, int b, const char *nn, int y);
VintagePort(const VintagePort &vp);
~VintagePort() {delete [] nickname;}
void Show() const;
friend ostream & operator<<(ostream &os, const VintagePort & vp);
};
My problem relates to the constructors, lines 8 and 26, displayed again:
Port(const char *br = "none", const char *st = "none", int b = 0);
VintagePort(const char *br, int b, const char *nn, int y);
How can a method definition be correctly written if the argument list has a missing base class argument (as is the case here), which is required for the base class constructor.