Assuming I am making a library of books in C++ this way:
#include <iostream>
#include <string>
#include <vector>
class Book
{
public:
     Book(string name, string author)
};
Simple, just a constructor, now I create a vector of Book and push books back:
int main()
{
   vector<Book> books;
   books.push_back(Book("Gatsby", "Fitzgerald"));
But when I try to print out some member (name or author):
   cout << books[0].name << endl;
   return 0;
}
My boy compiler is angry:
error: ‘__gnu_cxx::__alloc_traits >::value_type {aka class Book}’ has no member named ‘name’
     cout << books[0].name << endl;
I'm a relative beginner, does this approach make sense at all? And if it does, what did I do wrong?
Thank you!
 
    