#include
using namespace std;
class A
{
public:
A(){cout << "A" << endl;}
virtual ~A(){cout << "~A" << endl;}
};
class B : public A
{
public:
B(){cout << "B" << endl;}
~B(){cout << "~B" << endl;}
};
int main()
{
A *p = new B;
delete p;
system("pause");
return 0;
}
A *p = new B;这句为什么不new A呢?
这样写有没有什么现实需要?
有什么情况会必须这样写嘛?