class A
{
public:
void virtual read()
{
cout<<"base class A";
}
};
class B:public A
{
public:
void read()
{
cout<<"derived class B";
}
};
int main()
{
B obj();
clrscr();
obj.read();
getch();
}
/*int main()
{
B obj;
obj.read();
return 0;
}*/
int main()
{
B obj;
obj.A::read();
cout<<"\n";
obj.B::read();
return 0;
}
/*int main()
{
A obj1;
B obj2;
A*ptr;
ptr=&obj1;
ptr->read();
cout<<"\n";
ptr=&obj2;
ptr->read();
return 0;
}*/
麻烦请详细的解释每句。
临摹微笑
小怪兽爱吃肉