I am trying to use the erase function belonging to vector, but I am getting errors and I can not figure out why. I am getting different errors for it, but the ones i can understand dont make any sense, like no member function, or passing the wrong amount of arguments, I only want to pass the one argument.
errors are :
No matching member function for call to 'erase'clang(ovl_no_viable_member_function_in_call)
stl_vector.h(1317, 7): Candidate function not viable: no known conversion from 'int' to 'std::vector<int, std::allocator<int> >::const_iterator' (aka '__normal_iterator<const int *, std::vector<int, std::allocator<int> > >') for 1st argument
stl_vector.h(1344, 7): Candidate function not viable: requires 2 arguments, but 1 was provided
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int firstInt {};
vector <int> v {};
int vecInts {};
int rangeFirst {};
int rangeSecond {};
cin >> firstInt;
while (cin >> vecInts)
{
v.push_back(vecInts);
}
v.erase(firstInt);
for (auto n : v)
{
cout << n << " ";
}
return 0;
}
|