2011-01-13 68 views
0
class X_class{ 
public: 

struct extra 
{int extra1; 
int extra2; 
int extra3; 
}; 
enum a 
{ 
n,m}; 

struct x_struct{ 
char b; 
char c; 
int d; 
int e; 
std::map <int, extra> myExtraMap; 

}; 
}; 
在我的代碼

我定義:在結構中包含一個std :: map?可以嗎?

x_struct MYSTRUCT;

爲什麼我會編譯錯誤編譯上面的類?錯誤要麼說: 1)預期;之前<就行---我在那裏定義了地圖(上圖)如果我刪除std :: 或者 2)error:invalid use of ::;錯誤:預期; <令牌之前

+0

它編譯,爲什麼你說不要試試?讓我知道。 – user553514 2011-01-13 21:53:17

+0

@user - 附註:我看到你正在試圖弄清楚如何正確格式化你的代碼。只需全選,然後點擊{}按鈕。或者將所有行縮進4個或更多空格(這是{}按鈕的作用)。 – 2011-01-13 21:59:16

回答

8

也許你erorrs因爲你沒有#include <map>

相關問題