Q:

How to properly return an operator (*,/,-,+) in C++?

EDIT - thank you all for the help. I didnt even think of doing the switch statement. For some reason I keep thinking C++ is a lot different than Java... it makes a lot of sence with a switch.. thanks for bringing that to my attention.
How would I properly return an operator and use it once returned? I wrote a function to grab the operator from the input and check to make sure that its valid input.. this is the code I wrote for that (i called it doctor because I guess operator is a reserved name in C++ and doctors do operations haha... sorry.. just being silly)...:
string doctor()
{
    string getDoc;

    cin >> getDoc;

    if (getDoc == "*")
        return "*";

    if (getDoc == "/")
        return "/" ;

    if (getDoc == "-")
        return "-" ;

    if (getDoc == "+")
        return "+" ;

    else 
    {
        cout << "You entered " << getDoc << " please only use +,-,*,/ : ";
        return doctor();
    }
}

when the value is returned I have my main () do the following (it returns it into the "operation" variable...:
cout << firstNum << operation << secondNum << " is " << answer;

I have everything working except for that operator... how do I make that do what it needs to do.. in other words if its a * then multiply etc... 
sorry if this is basic, but I am new to C++, and googling for this didnt yield results...
thanks!

A:

You can case it the same way you have done in the function getting the input stream:
float result;
switch(operation) {
    case '*':
        result = firstNum * secondNum;
        break;
    case '/':
        result = firstNum / secondNum;
        break;
    case '+':
        result = firstNum + secondNum;
        break;
    case '-':
        result = firstNum - secondNum;
        break;
}
cout << firstNum << operation << secondNum << " is " << result;

