Home > Back-end >  C run results, big trouble to help me resolve this problem
C run results, big trouble to help me resolve this problem

Time:11-26

# include & lt; Iostream>
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
  • Related