//this function is takes in two arguments, a vector of type Vec and an element of type T, and returns //the number of elements that matched the argument and were successfully removed from the vector. The //order of the other elements should stay the same.
//I've added this to the .h file and tried to call this function from a test.cpp file with the lines:
int num_ele = remove_matching_elements(v, 22);
cout << num_ele << endl;
//where v is {11, 22, 33, 11, 55, 33}
template <class T> int remove_matching_elements(Vec<T>& v, const T& t) {
int counter = 0;
int i;
for(i = 0; i < v.size(); i++){
if(v[i] == t){
counter++;
while(i < v.size()-1){
v[i] = v[i+1];
}
v.resize(v.size()-1,0);
}
}
return counter;
}