我正在尝试定义一个类
class BTree
{
private:
map<std::string,BTree*> *node;
public:
BTree(void);
~BTree(void);
void Insert(BTree *);
};
编译代码时编译器给我一个错误
error C2899: typename cannot be used outside a template declaration
error C2143: syntax error : missing ';' before '<'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2238: unexpected token(s) preceding ';'
error C2899: typename cannot be used outside a template declaration
我试图将地图更改为像map<int,int> node
这样简单的地方,它仍然给我同样的错误。我错过了什么吗?
答案 0 :(得分:4)
这很可能是因为std
中没有列出using
命名空间。类型map
不在全局名称空间中,因此map
不可解析。请尝试以下
class BTree {
private:
std::map<std::string, BTree*> *node;
...
};