hi.. Im trying to assign varibles to a class[array] using the new operator in a for() loop however I am having problems.. When i cout the data, it is all blank, so the variables are never actually being set, however the data is being read in correctly to the variables... (the data exists).
Code:
int VAL = 200;
book *b1[VAL];
string title, author, publisher, month, year;
string dummy;
float price;
getline(bookList,title,';');
getline(bookList,author,';');
getline(bookList,publisher,';');
getline(bookList,month,';');
getline(bookList,year,';');
bookList >> price;
getline(bookList,dummy,'\n');
int size = 0;
while(!bookList.eof()) {
// THIS IS the line im having issues, with
b1[size] = new book(title, author, publisher, month, year, price);
getline(bookList, title,';');
getline(bookList, author,';');
getline(bookList, publisher,';');
getline(bookList, month,';');
getline(bookList,year,';');
bookList >> price;
getline(bookList, dummy);
size++;
}
for(int i = 0; i < size-1; i++) {
cout << "|" << b[i]->getTitle()
<< "|" << b[i]->getAuthor()
<< "|" << b[i]->getPublisher()
<< "|" << b[i]->getMonth() << "-" << b[i]->getYear()
<< "|" << "$" << b[i]->getPrice() << "|\n";
}
All of my getFunctions() simply return the variable that is suppose to be set by new..
any help greatly appreciated.