Possible en double:
How to find an item in a std::vector?RECHERCHE ou TROUVE intérieur du problème vectoriel
Compte tenu de ces deux 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.
}
Je veux chercher dans le vecteur du livre. Si le Livre est dans le vecteur du Livre, il ne fait rien. Si le livre est pas dans le vecteur du livre bookLists.push_back(ref);
Vous pourriez trouver [cette question] (http://stackoverflow.com/questions/571394/how-to-find-an-item-in-a-stdvector) utile. – Diederik