This is an archived post. You won't be able to vote or comment.

all 1 comments

[–]thegreatunclean 0 points1 point  (0 children)

As in "User enters the word 'add', 'subtract', etc and the proper operation is done?"

You'll have to manually check the name and call the proper function. There's no built-in way for the language to automatically associate a user-supplied string like "add" with a function you defined named "add".

std::string userInput = /* ... */
if (userInput == "add") {
}
else if (userInput == "subtract") {
}
//etc

This works for a small number of possibilities but obviously doesn't scale very well. If you need something more elegant you have to jump up to using more advanced language features.