title: How to apply arithmetic operation on strings in C++?
body: <p>I want to create a program that reads a string containing two numbers and a operator and prints out the results. It is continuously showing error on arithmetic operators. For instance, how would I add two strings together?</p>
  
  <pre><code>int main()
  {
      string number1;
      string number2;
      string operation;
      string answer;
  
      cout &lt;&lt; "Enter numbers with respective operations";
      cout &lt;&lt; "number 1";
      cin &gt;&gt; number1; 
      cout &lt;&lt; "number2";
      cin &gt;&gt; number2;
      cout &lt;&lt; "operation";
      cin &gt;&gt; operation;
      if (operation == "+")
      {
          answer = number1 + number2;
          cout &lt;&lt; "the sum is   " &lt;&lt; answer &lt;&lt; endl;
      }
      else if (operation == "-")
      {
          answer = number1 - number2;
          cout &lt;&lt; "the difference is   " &lt;&lt; answer &lt;&lt; endl;
      }
      else if (operation == "*")
      {
          answer = number1 * number2;
          cout &lt;&lt; "the product is   " &lt;&lt; answer &lt;&lt; endl;
      }
      else if (operation == "/")
      {
          answer = number1 / number2;
          cout &lt;&lt; "the answer is   " &lt;&lt; answer &lt;&lt; endl;
      }
      else
      {
          cout &lt;&lt; "invalid input" &lt;&lt; endl;
      }
      getchar();
      return 0;
  } 
  </code></pre>