<span style="font-size:18px;color:#000099;"><strong>#include <iostream>
using namespace std;
class A
{
public:
A()
{
cout<<"A";
}
~A()
{
cout<<"~A";
}
};
class B
{
A *p;
public:
B()
{
cout<<"B";
p=new A();//开辟动态存储,
}
~B()
{
cout<<"~B";
delete p;
}
};
int main()
{
B obj;
return 0;
}
</strong></span>
这个程序的运行顺序有点不太懂,单步执行只知道怎样输出的但不太清楚原理