I am trying to iterate over a vector and remove the first occurrence of an object. I keep getting a compile error (using g++), but I am removing it the way stackoverflow answers and other sources suggested removing it. There is probably something super simple that I'm missing, so another set of eyes would be great too.
#include <iostream>
#include <vector>
#include <assert.h>
using namespace std;
bool Garage::remove(const Car &car){
assert(!empty());
int size = v.size();
for(vector<Car>::const_iterator it = v.begin(); it != v.end(); ++it){
if(it -> Car::make() == car.Car::make()){
it = v.erase(it);
assert(v.size() == size - 1);
return true;
}
}
return false;
}
The compile error is error: no matching function for call to 'std::vector::erase(const Car&)'