1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
Library::Library(const string &pathBooks, const string &pathCards){
//use a temporary variables
string bookTitle, bookAuthor,name,phone,ISBN;
int bookStatus,ID,cardNumber,takenOut;
ifstream books(pathBooks.c_str(),ios::in);
ifstream cards(pathCards.c_str(),ios::in);
if(books && cards){
do{
getline(books,bookTitle,256,'\n');
getline(books,bookAuthor,256,'\n');
getline(books,ISBN,256,'\n');
books>>bookStatus>>ID;
vBooks.insert(Book(bookTitle,bookAuthor,ISBN,bookStatus,ID); //if 'Library has a 'vector<Book>' for the books and 'Book' has constructor with parameters
}while(books.good());
do{
getline(cards,name,256,'\n');
getline(cards,phone,256,'\n');
cards>>cardNumber>>takenOut;
vCards.insert(Card(name,phone,cardNumber,takenOut)); //if 'Library' has a 'vector<Card>' for the cards and 'Card' has constructor with parameters
}while(cards.good());
}
}
|