当我尝试声明我的类“游戏”的实例时,收到编译错误“error:'游戏'没有为main.cpp命名类型”。错误:'x'未命名类型
如果可能无关紧要,但我使用的是代码块。从Game.cpp
相关代码Main.cpp的
#include "../include/main.h"
class Game
{
private:
public:
};
相关代码
#include "../include/main.h"
Game g; //this is the line it is referring to
int main(int argc, char* args[])
{
return 0;
}
我才刚刚开始学习C++,所以我可能忽略了一些东西明显:(
在你Main.cpp的头文件,不包括类“游戏”的定义,所以你应该像Game.h一个文件中定义类游戏,和在你的Main.cpp中添加#include“Game.h” –