Dear all,

If i have a vector inside a vector creating a matrix, how do I delete a specific column in that matrix. I have already populated the 2d vector now i need a method to delete a specific column in that vector,

for example my vector would look like:

vector<vector<float> > vec;

Just for knowledge i know how to erase the rows in the vector as below:


// so What is the algorithm or code to delete a specific column in a vector of vector

Thank you for looking at this problem.

something like this should work vec[row].erase(vec[row].begin() + col);

You need to include a for clause to delete the required column on every row:
for(auto& r : vec) r.erase(r.begin()+col)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.