int main()之前应为主表达式
expected primary expression before int main()
我知道"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的文件中存在问题。
相关文章:
- 为什么随机数生成器不在void函数中随机化数字,而在main函数中随机化
- 代码在main()中运行,但在函数中出现错误
- (C++)分析树以计算返回错误值的简单算术表达式
- 在VS2010-VS2015下编译时,如何使用decltype作为较大类型表达式的LHS
- 提升精神:解析布尔表达式并简化为规范范式
- 不能在初始值设定项列表中将非常量表达式从类型 'int' 缩小到'unsigned long long'
- 使用正则表达式regex_search在字符串中查找字符串
- 如何确认我的constexpr表达式实际上已经在编译时执行
- 当我在main中声明了我的2d数组时,为什么我的程序会退出
- 概念中的cv限定符需要表达式参数列表
- 为什么constexpr的性能比正常表达式差
- 对于结构,表达式必须是可修改的ivalue
- QML:修改在不同QML文件(而非main.QML)中定义的子对象的属性
- 当一个值是非常量但用常量表达式初始化时使用constexpr
- 不确定要在我的main中放入什么才能使我的代码正常工作
- 为什么'class'和'main'中的相等表达式表现不同?
- main.cpp|45|error:"int" 和 "double" 之前的预期主表达式
- int main()之前应为主表达式
- 为什么下面的表达式 'd.f(1);' 在 main() 中没有歧义?
- Main()接受表达式吗?