I've also tried changing the code to
library.push_back(library.getBook(fin));
but it hasn't worked either :\
Also, ideally, I would like to be able to populate the whole class on the same vector. Then push back to a new object, and populate the whole thing before pushing back again. How would I approach that? Would I keep using push_back?
From what im imagining, if i created another constructor(function in object?)
1 2 3 4
|
void Library::getAuthor (ifstream fin)
{
fin >> author;
}
|
but wrote it as this in the populateVectors function:
1 2
|
library.push_back(getBook(fin)); //after this line in the function
library.push_back(getAuthor(fin));
|
would that just set author in the new vector[1] ?
To clarify, would it be allocated like this:
library[0].showBook()
library[1].showAuthor()
??
Because I am trying to make it so it is like this:
library[0].showBook()
library[0].showAuthor()
Sorry if its hard to understand what Im trying to say. I basically just want to have the 1st object filled fully instead of just filling 1 member of an object, and then pushing to another one.