Description
下面程序的输出结果是:
A::Fun
C::Do
程序代码
#include <iostream>
using namespace std;
class A {
private:
int nVal;
public:
void Fun()
{ cout << "A::Fun" << endl; }
void Do()
{ cout << "A::Do" << endl; }
};
class B:public A {
public:
virtual void Do()
{ cout << "B::Do" << endl; }
};
class C:public B {
public:
void Do( )
{ cout << "C::Do" <<endl; }
void Fun()
{ cout << "C::Fun" << endl; }
};
/* 括号内所填为该题答案 */
void Call(B& p)
{
p.Fun();
p.Do();
}
int main()
{
C c;
Call(c);
return 0;
}
原文地址:https://www.cnblogs.com/GyForever1004/p/9157097.html
时间: 2024-11-08 23:13:31