2014-10-28 38 views
-4

我知道什麼「預期主要表達式之前int」的意思,但我從來沒有見過在此上下文中使用的錯誤之前。它堅持指向我的程序頭(int main())。預期的主要表達式之前int main()

有人請賜教我這是什麼意思?我的大部分程序都以int main()開頭,沒有問題。

謝謝!

#include <string> 
#include <iostream> 
#include <vector> 
#include "Game.hpp" 


int main(){ // <---------------- Causing error 

    GameCell::Element wind("wind",10.0), 
         temp("temp",50.0), 
         precip("precip",0.0); 
    std::vector<GameCell::Element> testElements; 
    testElements.push_back(wind); 
    testElements.push_back(temp); 
    testElements.push_back(precip); 

    Game * test = new Game(3,testElements); 

    //GameCell GC(0, 0, 0, 0, 0, testElements, 1); 
    //GC.display(); 

    return 0; 
} 
+4

'Game.hpp'的內容是什麼? – jwodder 2014-10-28 02:27:31

+0

'game.hpp'裏有什麼? – John3136 2014-10-28 02:27:33

+1

錯誤必須在頭文件'Game.hpp'中 – jpw 2014-10-28 02:27:55

回答

3

您可能在"Game.hpp"標頭中缺少分號。

+0

是的,問題出在Game.hpp錯誤。這是我第一次在完全不同的文件上看到這個錯誤信息。學過的知識。 – SemperCallide 2014-10-28 02:39:28

0

我會仔細看看你的頭文件。該文件基本上寫入 包含主文件的文件。如果頭文件存在問題,它將導致 在包含main的文件中出現問題。