2011-10-20 107 views
0

我收到了一個錯誤,提示「房間初始化程序周圍缺少大括號」,但我明白錯誤的含義,我不明白爲什麼會這麼說。下面的代碼:缺少括號?哪裏?

//manager.h

class mapManager 
{ 
    public: 
    mapManager(); 

    private: 
}; 

class room //how the map tiles will have attributes. 
{ 
    public: 
    //public because room needs to be accessible from map manager 
    int dir; //direction of the current tile 
}; 

...

//manager.cpp (包括manager.h)

mapManager::mapManager() 
{ 
    room map[4][8] = { 
         {1, 2, 3, 4, 5, 6, 7, 8}, 
         {1, 2, 3, 4, 5, 6, 7, 8}, 
         {1, 2, 3, 4, 5, 6, 7, 8}, 
         {1, 2, 3, 4, 5, 6, 7, 8} 
        }; 
} 

我不看到任何失蹤的大括號!幫幫我?

+3

'房間'是什麼?它是如何定義的? – Joe

+3

我在gcc 4.6.1('typedef'ing'room'作爲'int')時沒有得到該代碼的錯誤。你能分享你的編譯器,並提供一些周圍的代碼嗎? – Nate

+0

我不認爲你錯過了任何大括號。它對我來說編譯得很好。你確定'房間'類型是被定義的嗎? – 2011-10-20 22:33:02

回答

0

我剛剛意識到,我只是假裝一個類是一個整數。感謝大家的意見。