Hello! I'm a very novice programmer and I'm having trouble with File input looping.
I'm reading from a list of books and their associated titles, cover types, pages, and weights. I've currently spent over an hour trying to figure out how to write this so that the loop continues on to the next grouping of data(title followed by cover type followed by page count, and ending on weight).
It currently prints out the first line correctly, then infinitely loops the first book's cover type, pages, and weight without the title. I've been spending a long time trying to figure this one out. Any help would be immensely appreciated, Thank you!
usingnamespace std;
enum Type
{
UNKNOWN = -1,
PAPERBACK,
HARDBACK
};
const string TYPE_WORDS[] = { "Paperback", "Hardback" };
class Book
{
public:
Book();
//constructor
Book( const string& name, Type type, int pages, float ounces );
//destructor
~Book(){};
string formatReportLine();
float getWeightLbs();
string getTypeName();
//accessors
string getName(){ return bName; };
Type getType(){ return bType; };
int getPages(){ return bPages; };
float getOunces(){ return bOunces; };
private:
string bName; //name of the book
Type bType; //the type of book
int bPages; //how many pages the book contains
float bOunces; //how much the book weighs in ounces
};