title: Error When Copying a Vector into another vector
body: <p>There are two vectors "ImgCoordinatesList" &amp; "ImgCoordinatesListCopy". </p>
  
  <p>The first vector continuously receives values which are pushbacked.(x,y,Type - I have previously defined a struct which has int,int,string and its object is list_obj)</p>
  
  <p>Once the function "ImgCreation" is called, the contents of the first vector should be copied into the "ImgCoordinatesListCopy" vector and the contents inside this copy vector should be used for further processing.</p>
  
  <p>But the method what i did produced errors.</p>
  
  <pre><code>void SliceImageNew::BuildImgCoordinatesList(const long X, const long Y, string Type)
  {
      //Creates the Structure for one x,y,type coordinate
      list_obj.x = X;
      list_obj.y = Y;
      list_obj.Coordinates_Type = Type;
  
      //Pushes the structure into a vector which eventually forms a vector of structs
      ImgCoordinatesList.push_back(list_obj);
  }
  
  void SliceImageNew::ImgCreation()
  {
      ImgCoordinatesListCopy.resize(ImgCoordinatesList.size());
      copy(ImgCoordinatesList.begin(), ImgCoordinatesList.end(), ImgCoordinatesListCopy.begin());
      //ImgCoordinatesListCopy = ImgCoordinatesList; //Copy the contents into another vector and create image with the copy vector
  
      ImgCoordinatesList.erase(ImgCoordinatesList.begin(), ImgCoordinatesList.end());//Clear the vector after copying the contents into another vector
      PlotImgCoordinates();
      //SaveSliceImg();
      //ClearImgCoordinatesList();
  
  }
  
  void SliceImageNew::PlotImgCoordinates()
  {
      static int SliceImgCount = 1;
      Mat SliceImg(Size(1920, 1080), CV_16UC3); // Blank Image with White Background and 1920*1080 Dimensions
      for (int i = 1; i!=ImgCoordinatesListCopy.size(); i++)
      {
          //Color differentiation between Mark and Jump Lines
          if (ImgCoordinatesListCopy[i].Coordinates_Type == "Mark")
          {
              //cout &lt;&lt; "This is a mark line" &lt;&lt; endl;
              line(SliceImg, Point(ImgCoordinatesListCopy[i - 1].x, ImgCoordinatesListCopy[i - 1].y), Point(ImgCoordinatesListCopy[i].x, ImgCoordinatesListCopy[i].y), Scalar(255, 255, 155), 4, 2, 0);
          }
          else
          {
              //cout &lt;&lt; "This is a jump line" &lt;&lt; endl;
              line(SliceImg, Point(ImgCoordinatesListCopy[i - 1].x, ImgCoordinatesListCopy[i - 1].y), Point(ImgCoordinatesListCopy[i].x, ImgCoordinatesListCopy[i].y), Scalar(255, 100, 155), 4, 2, 0);
          }
  
  
      }
  //Creating Legends for the Plot
      putText(SliceImg, "Mark Line", cvPoint(1600, 40),
          FONT_HERSHEY_SIMPLEX, 0.8, (255, 0, 0), 2);
      line(SliceImg, Point(1540, 35), Point(1590, 35), Scalar(255, 255, 155), 4, 2, 0);
  
      putText(SliceImg, "Jump Line", cvPoint(1600, 80),
          FONT_HERSHEY_SIMPLEX, 0.8, (255, 0, 0), 2);
      line(SliceImg, Point(1540, 75), Point(1590, 75), Scalar(255, 100, 155), 4, 2, 0);
  
      //Providing unique names for every picture that is being saved
      name &lt;&lt; "Slice" &lt;&lt; SliceImgCount &lt;&lt; ".jpg";
  
      // Saving the image 
      imwrite(name.str(), SliceImg);
      SliceImgCount++; //Increment the count to provide unique names to the images
      waitKey(0);
  }
  </code></pre>
  
  <p>I have attached an image which shows the code and the error generated <a href="https://i.stack.imgur.com/zPd6K.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zPd6K.jpg" alt="image"></a> </p>
  
  <p>While debugging, the highlighted line in the image produced that error!</p>
  
  <p>Could someone help me?</p>