#include
using namespace std;
class Ca{
public:
void do_down(void)
{
cout << "Ca down" << endl;
}
};
class Cb : public Ca
{
public:
void do_down(void)
{
cout << "Cb down" << endl;
}
};
class Cc : public Ca
{
public:
void do_down(void)
{
cout << "Cc down" << endl;
}
};
int main(void)
{
Ca *a1;
Cb b1;
a1 = &b1;
a1->do_down();
Cc c1;
a1 = &c1;
a1->do_down();
}
请教为什么编译运行后的结果是两个Ca down,而不是Cb down跟Cc down呢?