Im trying to make a program that erases the zeros in a vector but i get the error:
/Users/T_HEN1203/Documents/Stats.cpp|62|error: no matching member function for call to 'erase'
The reference i read said i could use a position to but that doesnt seem to be working
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
int main() {
std::vector<float> calc1 = {7, 5, 16, 8};
std::vector<float> calc2= {4, 5, 0, 8};
for (unsignedint x(0); x < calc1.size(); ++x) {
if (calc1.at(x) == 0 || calc2.at(x) == 0){
calc1.erase(calc1.at(x));
calc2.erase(calc2[x]);
}
}
}
else{
std::cerr<<"ERROR: The file isnt open.\n";
}
return 0;
}
Thanks to MrHutch i figured out how to remove the zeros but how would i remove the number from vector<float> calc2 that's at the same spot as vector<float> clac1?
I left the code above unchanged to help visualize what i'm talking about.