title: c++ std::out_of_range at memory location
body: <p>I'm trying to make a basic calculator where the user can enter 2 numbers and an operator and the calculation will work. I can't figure out why I am getting this error and I am not entirely sure what this error means because I am new to c++ having only had experience with some java. </p>
  
  <p>Here is what I have:</p>
  
  <p>Calculation.h</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  class Calculation{
  private:
      int x;
      int y;
  
  public:
      Calculation();
      int calculateAddition(int, int);
      int calculateSubtraction(int, int);
      int calculateMultiplication(int, int);
      int calculateDivision(int, int);
  };
  </code></pre>
  
  <p>Calculation.cpp</p>
  
  <pre><code>#include "Calculation.h"
  
  Calculation::Calculation(){
      x = 0;
      y = 0;
  }
  
  int Calculation::calculateAddition(int x, int y){
      return x + y;
  }
  
  int Calculation::calculateSubtraction(int x, int y){
      return x - y;
  }
  
  int Calculation::calculateMultiplication(int x, int y){
      return x * y;
  }
  
  int Calculation::calculateDivision(int x, int y){
      return x / y;
  }
  </code></pre>
  
  <p>Main.cpp</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;sstream&gt;
  #include &lt;string&gt;
  #include "Calculation.h"
  using namespace std;
  
  int main(){
  Calculation calc;
  int i = 0;
  char k;
  int x;
  int y;
  char j = 'a';
  string inputCalc;
  stringstream str;
  
  while(j != 'q'){
      cout &lt;&lt; "1. Make Calculation" &lt;&lt; endl;
      cout &lt;&lt; "2. Quit" &lt;&lt; endl;
      cin &gt;&gt; i;
      if(i == 1){
          cout &lt;&lt; "Input calculation:" &lt;&lt; endl;
          cin &gt;&gt; inputCalc;
          k = inputCalc.at(2);
          str &lt;&lt; inputCalc.at(1);
          str &gt;&gt; x;
          str &lt;&lt; inputCalc.at(3);
          str &gt;&gt; y;
          if (k == '+'){
              calc.calculateAddition(x, y);
          }
          else if (k == '-'){
              calc.calculateSubtraction(x, y);
          }
          else if (k == '*'){
              calc.calculateMultiplication(x, y);
          }
          else if (k == '/'){
              calc.calculateDivision(x, y);
          }
          else{
          }
      }
      else if(i == 2){
          j = 'q';
      }
      else{
          cout &lt;&lt; "Invalid input. Please enter 1 or 2." &lt;&lt; endl;
      }
  }
  }
  </code></pre>
  
  <p>EDIT: Ahhh thank you, I forgot that everything starts from 0. Silly me.</p>