Possible Duplicate:
How to find an item in a std::vector?
Given these two classes:
class Book
{
private:
string title;
int category;
public:
Book(const string& , int num);
}
Book(const string& name, int num)
:title(name), category(num)
{ }
class Reader
{
private:
string reader_name;
vector <Book> bookLists;
public:
void add(const Book &ref);
};
void add(const Book& ref)
{
// My problem is here.
}
I want to search inside the vector of Book. If the Book is in the vector of Book, it does nothing. If the Book is not in the vector of Book bookLists.push_back(ref);