find an item in a list of pointers

Viewed 6067

I am trying to understand how to find an item in a list of pointers in C++, using std::find

If I had for example:

std::list<string> words;
std::string word_to_be_found;

I could just search like this:

std::list<string>::iterator matching_iter = std::find(words,begin(), words.end(), word_to_be_found)

but what if I have a lsit of pointers?

std::list<string *> words;

the above syntax will not work anymore. Can I do it some similar way?

thanks!

3 Answers
Related