string Player::setPlayerName()
{
cout << "Please Enter Your name" << endl;
cin >> A;
return A;
}
int main()
{
Player me;
string name = me.setPlayerName();
}
Although there's really no point in storing it twice. You could just use a getter function:
1 2 3 4
string getPlayerName()
{
return A;
}
2. Use a loop + switch:
1 2 3 4 5 6 7 8 9 10 11 12
while(quit == false)
{
std::cin>>choice;
switch(choice)
{
case Q: quit = true; break; //Q for quit
case P: playGame(); break; //P for play
case I: printInstructions(); break; //I for instructions
}
}
//You'll obviously need to write playGame() and whatever else you want to implement
//but something like this will also make your code more modular which is a good thing.
Note: A is a terrible name for Name. Just call it "Name".