title: How to properly return an operator (*,/,-,+) in C++?
body: <p>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.</p>
  
  <p>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)...:</p>
  
  <pre><code>string doctor()
  {
      string getDoc;
  
      cin &gt;&gt; getDoc;
  
      if (getDoc == "*")
          return "*";
  
      if (getDoc == "/")
          return "/" ;
  
      if (getDoc == "-")
          return "-" ;
  
      if (getDoc == "+")
          return "+" ;
  
      else 
      {
          cout &lt;&lt; "You entered " &lt;&lt; getDoc &lt;&lt; " please only use +,-,*,/ : ";
          return doctor();
      }
  }
  </code></pre>
  
  <p>when the value is returned I have my main () do the following (it returns it into the "operation" variable...:</p>
  
  <pre><code>cout &lt;&lt; firstNum &lt;&lt; operation &lt;&lt; secondNum &lt;&lt; " is " &lt;&lt; answer;
  </code></pre>
  
  <p>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... </p>
  
  <p>sorry if this is basic, but I am new to C++, and googling for this didnt yield results...</p>
  
  <p>thanks!</p>