Why bother with MyMaxTries at all?

In the following function:

void FBullCowGame::Reset()
{
constexpr int MAX_TRIES = 3;
MyMaxTries = MAX_TRIES;
MyCurrentTry = 1;
return;
}

Why do we bother with creating a MyMaxTries variable at all if we are just going to declare a constexpr variable anyway? Couldn’t we just use MAX_TRIES in the code instead of MyMaxTries? Or is it so we can use either one based on what makes the code more readable? Or is MyMaxTries more readable in the first place, in which case why don’t we make MyMaxTries a constexpr instead?

(I set MAX_TRIES to 3 to make things easier for me when running the program)

Ok, after watching the video a few times I think I understand but correct me if I’m wrong.

The point here is just to have a variable that we only have in our code once so that we can easily look it up along with the magic number, correct? So technically, we could do as I said in the above post, but then we would have to change those variables in the code.

Privacy & Terms