#include "stdafx.h"
class C{
public:
~C(){ cout << "~C" << endl; }
};
class B:public C{
public:
~B(){ cout << "~B" << endl; }
};
int main(){
B b;
static_cast<C>(b);
(C)b;
}
/*
~C
~C
~B
~C
请按任意键继续. . .*/#include "stdafx.h"
class C{
public:
~C(){ cout << "~C" << endl; }
};
class B:public C{
public:
~B(){ cout << "~B" << endl; }
};
int main(){
B b;
C* pc;
pc = static_cast<C*>(&b);
pc = (C*)&b;
}