title: terminate called after throwing an instance of 'std::out_of_range'
body: <p>Why does this happen my program says that it has no errors but then when I run it I get terminate called after throwing an instance of 'std::out_of_range' what(): vector:_M_range_check.  I am new to c++ so I don't understand these errors</p>
  
  <pre><code>#include &lt;vector&gt;
  #include &lt;iostream&gt;
  #include &lt;random&gt;
  #include &lt;time.h&gt;
  
  using namespace std;
  using std::vector;
  
  int main()
  {
  
  vector&lt;int&gt; deck;
  vector&lt;int&gt; nums;
  default_random_engine eng(time(0));
  uniform_int_distribution&lt;int&gt; dis(0, 51);
  
  int pos1;
  int pos2;
  int num1;
  int num2;
  int i;
  int n;
  int m;
  
  for (i = 0; i &lt; 52; i++)
  {
      nums.push_back(i);
  
  }
  
  for(int j = 0; j &lt; 52; j++)
  {
      cout &lt;&lt; nums.at(i) &lt;&lt; "\n";
  }
  
  
  for(n = 0; n &lt; 50; n++)
  {
      pos1 = dis(eng);
      pos2 = dis(eng);
  
      cout &lt;&lt; pos1 &lt;&lt; "\n" &lt;&lt; pos2 &lt;&lt; "\n";
  
      num1 = deck.at(pos1);
      num2 = deck.at(pos2);
  
  }
  
  }
  </code></pre>