error C2955:
errorC2955:'BinTreeNode':useofclasstemplaterequirestemplateargumentlist是什么问题#include"...
error C2955: 'BinTreeNode' : use of class template requires template argument list
是什么问题
#include "BinTreeNode.h"
using namespace std;
template <class T>
class BinTree
{
BinTreeNode<T> * Tree_root;
public:
BinTree()
{
Tree_root = NULL;
}
BinTree(T data)
{
Tree_root = new BinTreeNode(data,NULL,NULL);
}
};
ifndef BINTREENODE_8_4
#define BINTREENODE_8_4
using namespace std;
template <class Type>
class BinTreeNode
{
Type Tree_Data;
BinTreeNode<Type> * Tree_leftChild;
BinTreeNode<Type> * Tree_rightChild;
public:
BinTreeNode()
{
Tree_leftChild = Tree_rightChild = NULL;
}
BinTreeNode( const Type & data,BinTreeNode* leftChild = NULL, BinTreeNode *rightChild =NULL)
{
Tree_Data = data;
Tree_leftChild = leftChild;
Tree_rightChild = rightChild;
}
Type & GetData()
{
return Tree_Data;
}
BinTreeNode<Type>* GetLeftChild()
{
return Tree_leftChild;
}
BinTreeNode<Type>* GetRightChild()
{
return Tree_rightChild;
}
void SetData(const Type &data)
{
Tree_Data = data;
}
void SetLeftChild(BinTreeNode<Type> *leftChild)
{
Tree_leftChild = leftChild;
}
void SetRightChild(BinTreeNode<Type> * rightChild)//BinTreeNode*与BinTreeNode<Type>*区别
{
Tree_rightChild = rightChild;
}
};
#endif //BINTREENODE_8_4
ain.cpp
1>e:\资料文件夹\设计代码\链式树实现\链式树\链式树\bintree.h(18) : error C2955: 'BinTreeNode' : use of class template requires template argument list
1> e:\资料文件夹\设计代码\链式树实现\链式树\链式树\bintreenode.h(8) : see declaration of 'BinTreeNode'
1> e:\资料文件夹\设计代码\链式树实现\链式树\链式树\bintree.h(16) : while compiling class template member function 'BinTree<T>::BinTree(T)'
1> with
1> [
1> T=char
1> ]
1> e:\资料文件夹\设计代码\链式树实现\链式树\链式树\main.cpp(10) : see reference to class template instantiation 'BinTree<T>' being compiled
1> with
1> [
1> T=char
1> ]
1>e:\资料文件夹\设计代码\链式树实现\链式树\链式树\bintree.h(18) : error C2514: 'BinTreeNode' : class has no constructors
1> e:\资料文件夹\设计代码\链式树实现\链式树\链式树\bintreenode.h(8) : see declaration of 'BinTreeNode'
1>Build log was saved at "file://e:\资料文件夹\设计代码\链式树实现 展开
是什么问题
#include "BinTreeNode.h"
using namespace std;
template <class T>
class BinTree
{
BinTreeNode<T> * Tree_root;
public:
BinTree()
{
Tree_root = NULL;
}
BinTree(T data)
{
Tree_root = new BinTreeNode(data,NULL,NULL);
}
};
ifndef BINTREENODE_8_4
#define BINTREENODE_8_4
using namespace std;
template <class Type>
class BinTreeNode
{
Type Tree_Data;
BinTreeNode<Type> * Tree_leftChild;
BinTreeNode<Type> * Tree_rightChild;
public:
BinTreeNode()
{
Tree_leftChild = Tree_rightChild = NULL;
}
BinTreeNode( const Type & data,BinTreeNode* leftChild = NULL, BinTreeNode *rightChild =NULL)
{
Tree_Data = data;
Tree_leftChild = leftChild;
Tree_rightChild = rightChild;
}
Type & GetData()
{
return Tree_Data;
}
BinTreeNode<Type>* GetLeftChild()
{
return Tree_leftChild;
}
BinTreeNode<Type>* GetRightChild()
{
return Tree_rightChild;
}
void SetData(const Type &data)
{
Tree_Data = data;
}
void SetLeftChild(BinTreeNode<Type> *leftChild)
{
Tree_leftChild = leftChild;
}
void SetRightChild(BinTreeNode<Type> * rightChild)//BinTreeNode*与BinTreeNode<Type>*区别
{
Tree_rightChild = rightChild;
}
};
#endif //BINTREENODE_8_4
ain.cpp
1>e:\资料文件夹\设计代码\链式树实现\链式树\链式树\bintree.h(18) : error C2955: 'BinTreeNode' : use of class template requires template argument list
1> e:\资料文件夹\设计代码\链式树实现\链式树\链式树\bintreenode.h(8) : see declaration of 'BinTreeNode'
1> e:\资料文件夹\设计代码\链式树实现\链式树\链式树\bintree.h(16) : while compiling class template member function 'BinTree<T>::BinTree(T)'
1> with
1> [
1> T=char
1> ]
1> e:\资料文件夹\设计代码\链式树实现\链式树\链式树\main.cpp(10) : see reference to class template instantiation 'BinTree<T>' being compiled
1> with
1> [
1> T=char
1> ]
1>e:\资料文件夹\设计代码\链式树实现\链式树\链式树\bintree.h(18) : error C2514: 'BinTreeNode' : class has no constructors
1> e:\资料文件夹\设计代码\链式树实现\链式树\链式树\bintreenode.h(8) : see declaration of 'BinTreeNode'
1>Build log was saved at "file://e:\资料文件夹\设计代码\链式树实现 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询