Hello programmers!
I am making a player vs. computer Tic-Tac-Toe game in xCode that is a class, with its run()
method as its only public member function apart from the initializer. I want to decide whether the player goes first, and I created a function to do that called determineFirst()
. This function depends on another one called askYesNoQuestion(const std::string& question)
to actually question the player as to him/her going first. My code is below:
bool determineFirst()
{
//ask player if he wants to play
static const string question="Do you want to play a game of Tic-Tac-Toe?";
return askYesNoQuestion(question);
}
bool askYesNoQuestion(const std::string& question)
{
static char ans;
//ask question
std::cout << question << " (yes/no): ";
std::cin.get(ans);
std::cout << std::endl;
//check if the answer is satisfactory (first letter of response only)
if((toupper(ans)!='N')||(toupper(ans)!='Y'))
{
std::cout << "That is not a valid answer to the question"<< std::endl;
bool yes=askYesNoQuestion(question);
return yes;
}
else
{
return toupper(ans)=='Y';
}
}
However, my xCode editor states that there is "No matching function for call to 'askYesNoQuestion'". This message is showing up on the return statement of determineFirst()
. What seems to be the problem