Welcome to collectivesolver - Programming & Software Q&A. A website you can trust. All programs tested and works. Contact: aviboots(AT)netvision.net.il
Hostgator 1 Penny

BlueHost Web Hosting

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

getflywheel wordpress hosting


Distribute your Resume to 500+ Job Boards & Recruiters


7,621 questions

10,674 answers

573 users

How to delete (erase) N vector items from specific position in C++

1 Answer

0 votes
#include <iostream>
#include <vector>

using std::cout;
using std::endl;
using std::vector;

int main()
{
	vector<int> vec = { 9, 1, 2, 3, 4, 7, 6, 8 };
	vector<int>::iterator it = vec.begin();

	it += 2;
	vec.erase(it, it + 4);

	for (it = vec.begin(); it != vec.end(); it++)
		cout << ' ' << *it;

	cout << endl;

	return 0;
}


/*
run:

9 1 6 8

*/

 




answered May 17 by avibootz
edited May 17 by avibootz
...