Why does "return Guess" return more than just variable value?

Just wondering why the following function returns all of the strings inside of it instead just the variable of “Guess” ??

My code works the same as the video but I’m just looking for clarification as to why.

//Player guess function
string GetGuessAndPrintBack() {
string Guess = “”;
//Get a guess from the player
cout << "Please enter your guess: ";
getline(cin, Guess);
//Repeat the guess back to them
cout << "You guessed: ";
cout << Guess << endl;
return Guess;
}

Privacy & Terms