In Private (I KNOW we aren't supposed to think about them yet :) ) making variables the result of functions

In my code, I had done things (completely by accident) a bit differently. Where Ben defines values for various variables (MyMaxTries, or WordLength f/e), like so:

int WordLength = 5; int MyCurrentTry = 1; int MyMaxTries = 5;

I had done it so that my private section in my header looked like this:

int WordLength();

And then in the FBullCowGame.cpp, I had

std::string FBullCowGame::MyMaxTries() { return 5; }

One is likely better than the other, however I figure that knowing both ways will be useful—because perhaps a value might be the result of a calculation rather than simply be assigned a static value.

I switched it over to his way just to keep my code somewhat in sync with his, but does anyone know if there is a reason you would not want to get a value in the way I originally did?

Privacy & Terms