#include
using namespace std;
Class A
{
Public:
Virtual void testfunc () const {cout & lt; <"A" & lt; Protected:
Private:
int i;
};
Class B: public A
{
Public:
Void testfunc () const {cout & lt; <"B" & lt; };
Class C: public B
{
Public:
Void testfunc () {cout & lt; <"C1" & lt; Void testfunc () const {cout & lt; <"C" & lt;
};
Int main ()
{
C C;
A. & amp; Pa=c;
C & amp; PC=c;
Pa. Testfunc ();
PC. Testfunc ();
Getchar ();
}
Why PC. Testfunc () output is c1, the layout of the object should be C
,
CodePudding user response:
Void testfunc (const)
Const often function, often function called when the object is often object to, CodePudding user response: