0 like 0 dislike
21 views
asked in C plus plus (C++) by (4.7k points)

How to I can remove vector element by index in C++?

vector drop element

Your answer

pre, code

Preview

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.

1 Answer

0 like 0 dislike
answered by (4.7k points)

The erase method on std::vector:

vectorArr.erase(vectorArr.begin() + index);

When you only want to erase a single element.

Related questions

0 like 0 dislike
1 answer 5 views
0 like 0 dislike
1 answer 8 views
0 like 0 dislike
1 answer 7 views
0 like 0 dislike
1 answer 7 views
0 like 0 dislike
1 answer 5 views
0 like 0 dislike
1 answer 136 views
0 like 0 dislike
1 answer 29 views
0 like 0 dislike
1 answer 9 views
0 like 0 dislike
1 answer 17 views
...