[英]map in class gives compile error
我正在嘗試定義一個類
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
那樣簡單map<int,int> node
它仍然給我同樣的錯誤。 我錯過了什么嗎?
這可能是因為您沒有在using
列出std
命名空間。 類型map
不在全局名稱空間中,因此map
不可解析。 請嘗試以下方法
class BTree {
private:
std::map<std::string, BTree*> *node;
...
};
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.