hi all,
I'm learning C++ and trying to understand how to handle vectors, specifically how to find an element of any type in a vector, then delete it.
I've been reading through my book which gives lots of theory and short examples, and some google searches have turned up more errors than my own attempts! I'd apprecite a bit of guidance please, here is my test attempt, which fails on the std::find line
#include <iostream>
#include <vector>
void displayvec(std::vector<std::string>&);
int main ()
{
std::vector<std::string> test {"Knife", "Boat", "Gun", "Water"};
displayvec(test);
test.erase(test.begin()+2);
displayvec(test);
auto it = std::find(test.begin(), test.end(), "Boat");
return 0;
}
void displayvec(std::vector<std::string>&v)
{
for (std::string s : v )
{
std::cout << s << std::endl;
}
}
How do I find and delete Boat?