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
and one of 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.. };
Now my doubt is with this line..in the derived class..Code:class book:public media { int pages; public: book(char *s,float a,int p):media(s,a) { pages = p; } void display(); };
i understand that this is a constructor with 3 parameters..Code:book(char *s,float a,int p):media(s,a)
but why is this included..
is the constructor derived..?? or what..??Code::media(s,a)
can someone please clarify..!!!!



LinkBack URL
About LinkBacks



