//--------------------------------------------------- //operator> //overwrite the operator> //@param book the book that compare to //@return true if grater than, false if smaller bool Periodical::operator>(const Publication& book)const{ if(year > book.getYear()) return true; //year is greater else if(year == book.getYear()){ //year is equal -> check month if(month > book.getMonth()) return true; //month is greater else if(month == book.getMonth()){ //month is equal -> check title return thisBookTitle > book.getTitle(); }else return false; //month is smaller }else //year is smaller return false; }
//--------------------------------------------------- //operator== //overwrite the operator== //@param book the book that compare to //@return true if equals, false if not bool Periodical::operator==(const Publication& book)const{ return (year == book.getYear() && month == book.getMonth() && thisBookTitle == book.getTitle() && thisBookType == book.getType()); }