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()會出錯
以下代碼中,關于c++二叉樹類中maketree函數存在什么問題,該怎么改?
慕田峪7331174
2022-03-18 11:11:07