/* In the given scenario, it is not possible to achieve polymorphism in the 2nd level, because "cards" is an abstract class. To achieved the desired results, we must make the "cards" class as a concrete class. */ #include #include class cards{ // Protected data members protected: int id; char * name; public: // Making displayCards() as a pure virtual function, as a result the cards class becomes an abstract class virtual void displayCards()=0; }; class MarriageCards:public cards { // Inheritance relationship b/w MarriageCards and cards // public interface of MarriageCards class public: MarriageCards(){ // User defined default class id=0; name=NULL; } MarriageCards::MarriageCards(int _id, char * _name){// Overload constructor id=_id; name=new char[strlen(_name)+1]; strcpy(name,_name); } // Overriding the displayCards() method virtual void displayCards(){ cout<<"You are now going to see the Marriage Cards"<displayCards();// call the mehindiCards displayCards() methodthrogh the reference of MarriageCards MarriageCards* bcards= new BaraatCards(2,"XYZ");// Creating reference of MarriageCards class // and calling the overloaded constructor of BaraatCards class bcards->displayCards();// call the BaraatCards displayCards() methodthrogh the reference of MarriageCards MarriageCards* wcards= new WalimaCards(3,"PQR");// Creating reference of MarriageCards class // and calling the overloaded constructor of WalimaCards class wcards->displayCards();// call the WalimaCards displayCards() methodthrogh the reference of MarriageCards system("pause"); }