lundi 25 décembre 2017

arranging elements of vector after using erase()

/*
for ( i=1; i<=10; i++) myvector.push_back(i);

  // erase the 6th element
  myvector.erase (myvector.begin()+5);

  // erase the first 3 elements:
  myvector.erase (myvector.begin(),myvector.begin()+3);

  cout << "myvector contains:";
  for (i=0; i<myvector.size(); ++i)                   */

Is there any way by which I can manipulate erase function so that I don't have to start after i=0 and instead I can store elements from i=1(basically I want to preserve the 1 indexing)./* These code stores elements as 0 indexing although I stored them in 1 indexing. I think the erase function manipulates it */

Aucun commentaire:

Enregistrer un commentaire