C++使用类模板需要模板参数列表,用了两个类模版

2024-12-09 07:49:53
推荐回答(1个)
回答(1):

node也是模板类,所以都需要写成node*,修改如下:
template
struct node
{
Type root;
node *left,*right;
};
template
class tree
{
node* head;
unsigned int tree_size;
public:
tree();
node *create();
void destory();
void NLR(node *);
void LNR(node *);
void LRN(node *);
unsigned int size();
node *root();
};
template
void tree::NLR(node *temp) //报错???
{
if(temp)
{
cout<root;
NLR(temp->left);
NLR(temp->right);
}
}
这样写貌似还缺少构造函数,不知你下面是不是写了