【发布时间】:2017-11-27 16:24:30
【问题描述】:
我正在为井字游戏创建代码,如果他们选择的插槽已满,我会尝试使用 void 函数再次尝试。这是我的 boardInput() 和 tryAgain() 代码:
void boardInput()
{
int a;
cout << "Round: " << iRound << endl;
cout << "Row: ";
cin >> a;
int b;
cout << "Column: ";
cin >> b;
if (a == 1 && b == 1)
{
if (chGrid[0][0] == '-')
chGrid[0][0] = chPlayer;
else
{
tryAgain();
}
}
}
void tryAgain()
{
system("cls");
displayBoard();
cout << "ERROR! Try again!" << endl;
boardInput();
}
我试图移动 void ,但仍然遇到同样的错误。谁能帮帮我?
【问题讨论】:
-
在 C++ 中,符号必须在使用前声明。做一些关于前向声明的研究。并注意可能的深度递归,请考虑使用循环的解决方案。
标签: c++ arrays void identifier tic-tac-toe