10 1 C:\Users\X250\Desktop\井字棋.cpp [Warning] scoped enums only available with -std=c++11 or -std=gnu++11 121 28 C:\Users\X250\Desktop\井字棋.cpp [Error] '>>' should be '> >' within a nested template argument list C:\Users\X250\Desktop\井字棋.cpp In constructor 'TicTacToe::TicTacToe()': 21 45 C:\Users\X250\Desktop\井字棋.cpp [Error] expected primary-expression before '(' token 21 52 C:\Users\X250\Desktop\井字棋.cpp [Error] 'CellState' is not a class or namespace C:\Users\X250\Desktop\井字棋.cpp In member function 'void TicTacToe::displayBoard()': 29 26 C:\Users\X250\Desktop\井字棋.cpp [Error] 'CellState' is not a class or namespace 32 26 C:\Users\X250\Desktop\井字棋.cpp [Error] 'CellState' is not a class or namespace 35 26 C:\Users\X250\Desktop\井字棋.cpp [Error] 'CellState' is not a class or namespace C:\Users\X250\Desktop\井字棋.cpp In member function 'bool TicTacToe::makeMove(int, int, CellState)': 56 84 C:\Users\X250\Desktop\井字棋.cpp [Error] 'CellState' is not a class or namespace C:\Users\X250\Desktop\井字棋.cpp In function 'int main()': 128 31 C:\Users\X250\Desktop\井字棋.cpp [Error] 'CellState' is not a class or namespace 133 48 C:\Users\X250\Desktop\井字棋.cpp [Error] 'CellState' is not a class or namespace 138 56 C:\Users\X250\Desktop\井字棋.cpp [Error] 'CellState' is not a class or namespace 142 47 C:\Users\X250\Desktop\井字棋.cpp [Error] 'CellState' is not a class or namespace 142 63 C:\Users\X250\Desktop\井字棋.cpp [Error] 'CellState' is not a class or namespace 142 78 C:\Users\X250\Desktop\井字棋.cpp [Error] 'CellState' is not a class or namespace
根据您提供的错误信息,有几个问题需要解决:
[Warning] scoped enums only available with -std=c++11 or -std=gnu++11
这个警告意味着您的编译器可能不支持C++11标准或更高版本。为了解决这个问题,您可以在编译命令中添加-std=c++11
或-std=gnu++11
选项,以启用C++11特性。例如,使用以下命令编译代码:g++ -std=c++11 TicTacToe.cpp -o TicTacToe
[Error] '>>' should be '> >' within a nested template argument list
这个错误是因为在代码中的输入语句cin >> row >> col;
中,>>
符号被误认为是嵌套模板参数列表。为了解决这个问题,您可以将>>
之间添加一个空格,使其变成> >
,即cin >> row >> col;
。[Error] expected primary-expression before '(' token
这个错误是因为构造函数TicTacToe::TicTacToe()
的定义位置不正确。请将构造函数的定义移动到类的外部,例如将构造函数定义移动到类声明的后面。[Error] 'CellState' is not a class or namespace
这个错误是因为编译器无法识别CellState
枚举类。请确保在使用CellState
之前已经正确定义了该枚举类。或者,您可以尝试将枚举定义放在TicTacToe
类的前面,以确保在使用之前已经声明。
请尝试根据上述解决方案修复代码中的错误,并重新编译运行。如果您仍然遇到问题,请提供更新后的错误信息,我将尽力帮助您解决问题。
相关推荐



















