Reputation: 14098
I wish to avoid switch statement by defining a pointer to a vector. I need help to use insert and erase methods.
bool selectFirst = true;
std::vector<int> v1, v2;
std::vector<int> *v = selectFirst ? &v1 : &v2;
v->push_back(0);
But how to insert or erase values from v ???
Thank you
Upvotes: 0
Views: 408
Reputation: 29001
Well, the same way you used push_back
, you can use erase
... Look at the documentation for those operations in the STL. For example, deleting the first element:
v->erase( v->begin() );
Upvotes: 2