I’m fairly sure I have Ben’s exact code copied, but the compiler says I have an error on line 19 that ‘std::string’: illegal use of this type as an expression
I really don’t have any idea what it’s telling me is wrong, here’s my code
#include <iostream>
#include <string>
using namespace std;
void PrintIntro();
string GetGuessAndPrintBack();
// Entry point for application
int main()
{
PrintIntro();
GetGuessAndPrintBack();
GetGuessAndPrintBack();
cout << endl;
return 0;
}
// get a guess from player
string GetGuessAndPrintBack() {
string Guess = "";
cout << "Answer: ";
getline(cin, Guess);
// repeat guess back to them
cout << "Your Guess was: " << Guess << endl;
return Guess;
}
// introduce the game
void PrintIntro() {
constexpr int WORD_LENGTH = 5;
cout << "Welcome to Bulls and Cows, a fun word game.\n";
cout << "Can you guess the " << WORD_LENGTH;
cout << " letter isogram I'm thinking of?\n";
cout << endl;
return;
}
any help would be appreciated, thanks!