Hi all,
Quick question: This is the only thing left I'm trying to work out on my console program. I am trying to return control back to the point where a user enters their selection after giving an invalid entry. I am using switch statements that house the selections, and I'm a little vague on how to allow them to re-enter a correct selection under the 'default' switch.
Here is the piece of code I'm having trouble with:
char Derived::getSelection(char selection)
{
cout <<"\nPlease enter your selection: ";
cin >> selection;
selection = toupper(selection);
cin.get();
switch (selection)
{
case 'A':
cout <<"\nYou have selected New Game"; //no functionality yet
break;
case 'B':
cout <<"\nYou have selected Load Game"; //no functionality yet
break;
case 'C':
showHiScore(HiScore);
break;
default:
cout <<"\nInvalid selection. Please re-enter your selection: ";
cin >> selection;
}
return selection;
//getSelection() definition
}
Any advice or direction would be appreciated greatly.