65,186
社区成员




class A
{
public:
int num;
A *parent;
vector<A *> children;
...
// 无参数调用
A(void)
{
this->num = 3;
this->parent = 0;
for (int i=0;i<this->num;++i)
this->children.push_back(new A(this,this->num-1));
}
// 子构造函数,被上面的无参函数调用
A(A *a,int n)
{
this->num = n;
this->children->parent = a;
for (int i=0;i<this->num;++i)
this->children.push_back(new A(this,this->num-1));
}
};
void deallocate(pointer _Ptr, size_type)
{ // deallocate object at _Ptr, ignore size
::operator delete(_Ptr);
}
A::~A(void)
{
if (this->parent!=0) this->parent = 0;
for (int i=0;i<(int)this->children.size();++i)
this->children[i]->~A();
vector <A *> ().swap(this->children);
}