Can't make the getter work properly

I followed the video exactly as far as I know, and have rebuilt and restarted to try and fix it.

Here’s my PlayGame code after Ben’s corrections:

void PlayGame()
{
FBullCowGame BCGame; //instantiate. To create an instance of something
int MyMaxTries = BCGame.GetMaxTries();
std::cout << MyMaxTries << std::endl;

// loop the questions and answers
for (int Count = 1; Count <= MyMaxTries; Count++)
{
std::string Guess = GetGuess();
std::cout << "Your guess was : " << Guess << std::endl;
std::cout << std::endl;
}
}

Here’s the private variables from my header:

private:
int MyCurrentTry;
int MyMaxTries = 5;
bool isIsogram;
};

I have no idea how to fix this. Please help!

What’s going wrong?

Hi Sam,

The maximum tries count was always outputting zero, but I worked it out. I hadn’t set GetMaxTries to output MyMaxTries in the header file. So it wasn’t being given any value.

1 Like

Privacy & Terms