template<class T>
class bit
{
private:
struct node
{
node *le;
node *ri;
T data;
};
node *root;
void clear(node*t)
{
if(t->le!=NULL)clear(t->le);
if(t->ri!=NULL)clear(t->ri);
delete t;
}
public:
bit(){root=new node;root->le=NULL;root->ri=NULL;}
bit(T x){root=new node;root->data=x;root->le=NULL;root->ri=NULL;}
void clear(){if(root!=NULL)clear(root);root=NULL;}
void maketree(T x,bit lr,bit rr)
{
root=new node;
root->data=x;
root->le=lr.root;
root->ri=rr.root;
lr.root=NULL;
rr.root=NULL;
}
}
执行maketree后再执行清空clear()会出错
德玛西亚99