65,210
社区成员
发帖
与我相关
我的任务
分享
class A
{
void print()
{
cout<<"A";
}
};
class B:B
{
int b;
void print()
{
cout<<"B";
}
};
int main()
{
A * a = new A;
B * b = static_cast<B*>(a);
b->print();
a->print();
b->b = 0;
cout<<b->b;
}
A * a = new A;
int x;
B * b = (B*)(&x);
b->print();
a->print();
b->b = 0;
cout<<b->b;
B * c = 0;
c->print();