So, I had a bit of a philosophical issue assigning MAXTRIES as a const inside the FBBullCow object. My thinking here is that each time the object is instantiated – or, reset, even – the caller may wish to control the number of tries. Maybe that’s thinking too much (or, more likely, too little) about it, but I ended up:
in main.cpp
const int MAX_TRIES = 8;
.
.
.
BCGame.Reset(MAX_TRIES);
in FBullCowGame.h
private:
int MyMaxTries;
in FBullCowGame.cpp
FBullCowGame::FBullCowGame()
{
Reset(1); \explcitly set to 1 so that if it only loops once, I know I screwed the pooch…
return;
}
.
.
.
void FBullCowGame::Reset(int MyMaxTriesIN)
{
MyMaxTries = MyMaxTriesIN;
return;
}
So…the challenge is two-fold. One, first I tried to pass that into the constructor, but found out that was a no-no. Second, I see that by doing this, I cannot make int MyMaxTries const in the .h file – the compiler obviously doesn’t like me changing the value.
Is there another way to protect it from being munged? Is this a bad idea/approach?