int main()之前应为主表达式

expected primary expression before int main()

本文关键字:表达式 main int      更新时间:2023-10-16

我知道"int之前的预期主表达式"是什么意思,但我以前从未见过在这种上下文中使用过错误。它一直指向我的程序头(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;
}

"Game.hpp"标头中可能缺少分号。

我会详细查看您的头文件。该文件基本上已写入您的文件包含main。如果头文件出现问题,将导致包含main的文件中存在问题。