Didn't I do exactly what you're asking in the changes I made to your program? Well as a matter of fact yes, yes I did:
Code:
char type = std::toupper(str[0]);
if (type == 'Q')
return;
else if (type == 'A') {
// ...
return;
}
else if (type == 'Y') {
int newCurr = std::atoi(str.substr(1).c_str());
if (newCurr < 0 || newCurr >= NUM_CURR)
return;
_curr = (Currency)(newCurr - 1);
}
So the variable "type" contains the first character of the input. Use isalpha(type) to check that it is an alphabetic character. And the check to insure the numeric part is within a certain range is already included.
Yours is such a limited and specific use that creating a class/struct would be overkill.