1

我正在尝试定义一个类

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它仍然给我同样的错误一样。我错过了什么吗?

4

1 回答 1

4

这可能是因为您没有stdusing. 该类型map不在全局命名空间中,因此map无法解析。尝试以下

class BTree {
private:
  std::map<std::string, BTree*> *node;

  ...
};
于 2012-10-19T17:20:39.067 回答