Code:
std::vector<int> PutNumbers;
PutNumbers.push_back(1);
PutNumbers.push_back(2);
PutNumbers.push_back(3);
//Result
PutNumbers[0] = 1;
PutNumbers[1] = 2;
PutNumbers[2] = 3;
I have this code above where I push_back numbers to 3 elements.
I am reading these numbers from a file but when I will read the fourth number wich could be 4 I want to replace the vector so it will look like below.
I know I can do this manually by iterate trough the elements etc.. This is not a problem.
But I wonder if there is any function for this for the std::vector to easy achive this. I have searched around but havn´t found anything about that subject.
Thank You!
Code:
PutNumbers.push_back(4);
//Result
PutNumbers[0] = 2;
PutNumbers[1] = 3;
PutNumbers[2] = 4;