using namespace std;
Class C
{public:
Virtual string toString () {return "C". } virtual int toInt () {return 100; }
Void the print () {cout & lt; <"Class C" & lt;
Class B: public C
{public:
String toString () {return "B"; }
Void the print () {cout & lt; <"Class B" & lt;
Class A: public B
{public:
String toString () {return "A"; } int toInt () {return 300; }
};
Void displayObject (C * p) {cout & lt; <'\ t'; P - & gt; Print (); }
Int main ()
{A, A. B B; C C;
DisplayObject (& amp; A); DisplayObject (& amp; b); DisplayObject (& amp; c); Amy polumbo rint (); P. rint (); C.p rint ();
return 0;
}
CodePudding user response:
Covered with polymorphism, step through yourself,CodePudding user response:
Chaos code, parse