Quick Question

When I did the challenge I used

cout << "Your guess: " << GetGuess() << endl;

But in the solutions i noticed that he declared a variable and set it equal to the return value of the function. Is what I did (code above) bad practice? if so, could someone explain why?

Entirely depends on what you plan on doing with it. If all you are doing with it is plugging it into cout then I don’t see the need for storing it in a variable.

1 Like

Okay, thats what i thought as well. Sorry, I come from a java background where we call methods such as that very often. I just wasn’t sure if there was some sort of c++ convention that says not to do that. Thanks again Dan.

Privacy & Terms