title: Using std::find with a custom Book class
body: <p>Here is my main:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include "Book.h"
  
  using namespace std;
  
  vector&lt;Book&gt; removeDuplicates(vector&lt;Book&gt; oldbookvector)
  {
      vector&lt;Book&gt; newbookvector;
      vector&lt;string&gt; booknames;
  
      for(vector&lt;Book&gt;::size_type i = 0; i &lt; oldbookvector.size(); i ++){
          booknames.push_back(oldbookvector[i].bookname());
      }
  
      vector&lt;Book&gt;::iterator it;
      for(vector&lt;Book&gt;::size_type i = 0; i &lt; oldbookvector.size(); i ++){
          //If it find a value then it returns the first element
          it = find(newbookvector.begin(),newbookvector.end(), oldbookvector[i]);
          if(it == newbookvector.end()){
              booknames.push_back(oldbookvector[i].bookname());
          }
      }
  
      return newbookvector;
  }
  
  int main(int argc, const char * argv[])
  {
      vector&lt;Book&gt; books;
      vector&lt;Book&gt; newbooks;
  
      books.push_back(Book("The C Programming Language", 1980));
      books.push_back(Book("Javascript: The Good Parts", 2008));
      books.push_back(Book("Accelerated C++: Pratical Programming by Example", 2000));
      books.push_back(Book("Scala for the Impatient", 2012));
      books.push_back(Book("The C Programming Language", 1980));
      books.push_back(Book("Javascript: The Good Parts", 2008));
      books.push_back(Book("Accelerated C++: Pratical Programming by Example", 2000));
      books.push_back(Book("Scala for the Impatient", 2012));
  
      cout &lt;&lt; &amp;books[2] &lt;&lt; endl;
      cout &lt;&lt; books[2].bookname() &lt;&lt; endl;
  
      //Test to make sure book class was working
      Book stuff = Book("The Book about stuff", 1998);
      cout &lt;&lt; stuff.bookname() &lt;&lt; endl;
      cout &lt;&lt; stuff.bookyear() &lt;&lt; endl;
  
      stuff.printBook();
  
      //newbooks = removeDuplicates(books);
  
      //Print out the vector without duplicates
      for(vector&lt;Book&gt;::size_type i = 0; i &lt; newbooks.size(); i ++){
          cout &lt;&lt; newbooks[i].bookname() &lt;&lt; newbooks[i].bookyear() &lt;&lt; "\t";
      }
  
      return 0;
  }
  </code></pre>
  
  <p>I keep getting an error in algorithm.cc that says "Invalid operands to binary expression ('Book' and 'const Book')". I think it is coming from the find(). Im pretty sure the problem is the iterator is not iterating  through the books</p>
  
  <p>Here is my Book class</p>
  
  <pre><code>#ifndef Question2_Book_h
  #define Question2_Book_h
  using namespace std;
  
  class Book{
  public:
      Book();
  
      Book(string n, int y){
          name = n;
          year = y;
      }
  
      string bookname(){
          return name;
      }
      int bookyear(){
          return year;
      }
  
      void printBook(){
          cout &lt;&lt; name &lt;&lt; ", " &lt;&lt; year &lt;&lt; endl;
      }
  
  private:
      string name;
      int year;
  };
  #endif
  </code></pre>