i was going through a program on run-time polymorphism and i encountered a program which had 1 base class and 2 classes derived from the base class..
the base class is as follows
Code:
class media
{
protected:
char title[50];
float price;
public:
media(char *s,float a)
{
strcpy(title,s);
price = a;
}
virtual void display() { } // empty virtual function..
};
and one of the base class is as follows..
Code:
class book:public media
{
int pages;
public:
book(char *s,float a,int p):media(s,a)
{
pages = p;
}
void display();
};
Now my doubt is with this line..in the derived class..
Code:
book(char *s,float a,int p):media(s,a)
i understand that this is a constructor with 3 parameters..
but why is this included..
is the constructor derived..?? or what..??
can someone please clarify..!!!!