Question: How should I change the code so that getUserOption receives strings such as help, help average as input instead of integers like 1, 2, 3?

How should I change the code so that getUserOption receives strings such as "help", help average" as input instead of integers like 1, 2, 3?

int MerkelMain::getUserOption() { int userOption = 0; std::string line; std::cout << "Type in 1-6" << std::endl; std::getline(std::cin, line); try{ userOption = std::stoi(line); }catch(const std::exception& e) { // } std::cout << "You chose: " << userOption << std::endl; return userOption; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!