I have defined a enum class:
And another class:Code:enum class Genre { fiction, nonfiction, periodical, biography, children };
I am stuck because I am not able to directly input values because I am not able to correctly set helper function. I had to create two different ones:Code:class Book { public: string f_title() { return title; } string f_author() { return author; } string f_isbn() { return isbn; } Genre f_genre() { return g; } int f_day(); int f_month(); int f_year(); Book(string tit, string aut, string isbn, Genre g); Book(string tit, string aut, string isbn); Book(); class Invalid {}; private: string isbn, title, author; int day, month, year; Genre g; };
but my program skips the Genre helper function and returns to me the default value "N/A".Code:istream& operator>>(istream& is, Book& n) { string title, author, isbn; getline(is,title); getline(is,author); getline(is,isbn); isbn.resize(7); if (!is) return is; n = Book{ title,author,isbn }; return is; } istream& operator>>(istream& is, Genre& g) { int i; is >> i; g = (Genre)i; return is; }
How can I fix it?
Thanks!




Reply With Quote
