title: Vector subscript out of range error - C++ Vectors & Open CV
body: <p>I am writing a program that would collect some coordinates and push them into a vector and finally send these vectors to a function that would create an image and plot the points present in these vectors. </p>
  
  <p>My Program :</p>
  
  <pre><code>#include&lt;opencv\cv.h&gt;
  #include&lt;opencv\highgui.h&gt;
  #include&lt;iostream&gt;
  #include&lt;vector&gt;
  using namespace cv;
  using namespace std;
  
  
  void image_creator(vector&lt;float&gt;  jump_xx, vector&lt;float&gt;  jump_yy, vector&lt;float&gt;  mark_xx, vector&lt;float&gt;  mark_yy)
  {
  
      Mat image_creator(Size(500, 500), CV_8UC3);
  
      for (int i = 0; i &lt; sizeof(jump_xx); i++)
      {
          line(image_creator, Point(jump_xx[i], jump_yy[i]), Point(mark_xx[i], mark_yy[i]), Scalar(155, 122, 155), 4, 2, 0);
          waitKey(0);
      }
      namedWindow("Slice_Viewer1", CV_WINDOW_FREERATIO);
      imshow("Slice_Viewer1", image_creator);
  
  }
  
  int main()
  {
      vector&lt;float&gt; jump_x;
      vector&lt;float&gt; jump_y;
      vector&lt;float&gt; mark_x;
      vector&lt;float&gt; mark_y;
  
      int x, y, a, b;
      int choice;
  
      jump_x.push_back(0.0);
      jump_y.push_back(0.0);
  
      mark_x.push_back(0.0);
      mark_y.push_back(10.0);
  
      jump_x.push_back(10.0);
      jump_y.push_back(0.0);
  
      mark_x.push_back(10.0);
      mark_y.push_back(10.0);
  
      image_creator(jump_x, jump_y, mark_x, mark_y);
  
      return 0;
  
  }
  </code></pre>
  
  <p>The build is successful but when i run the code , i get this error:</p>
  
  <p><a href="https://i.stack.imgur.com/WQ5wc.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WQ5wc.jpg" alt="enter image description here"></a></p>