#include <iostream>
using namespace std;
class A{
public:
A(int i){
cout << i << " Constructor of A" << endl;
}
A(){
cout << "Constructor of A" << endl;
}
~A(){
cout << "Desconstructor of A" << endl;
}
};
class B:public A{
public:
//注意静态成员对象比较特殊,会在编译期间进行初始化
static A a1;
A a2;
A a3;
B():a2(A(2)){
cout << "constructor of B" << endl;
}
~B(){
cout << "Desconstructor of B" << endl;
}
};
A B::a1=A(1);
int main()
{
B b;
return 0;
}