Hello there,
I was at section 2, lecture 26 and after many times I got annoyed about 1 thing lol
As an example, we were implementing GetCurrentTry() that is in a class FBullCowGame with instance BCGame inside the GetGuess() function.
For that Ben went and, again, created a local variable for it even if he is not changing it ever.
So I did this:
"
std::cout << "Try " << BCGame.GetCurrentTry() << “: What is your guess?” << std::endl;
std::string Guess;
std::getline(std::cin, Guess);
"
between other things and Ben went and did:
"
int CurrentTry = BCGame.GetCurrentTry();
std::cout << "Try " << CurrentTry << ". Enter your guess: “;
std::string Guess = “”;
std::getline(std::cin, Guess);
”
So what I wonder is 2 things:
- Why do local variables when the value is being managed inside the class? Isn’t more efficient my way or is it wrong?
- Why initialize all variables? like Ben initializes “Guess” while I dont see the point since it will be initialized the next line with getline()
Thanks