Question: Imagine you're developing a system for a library to manage its catalog of books. Each book in the catalog is represented by a class that

Imagine you're developing a system for a library to manage its catalog of books. Each book in the catalog is represented by a class that includes details such as the title and the number of pages. Your task is to create functionality that allows for easy display of book details to the library's digital catalog interface, using operator overloading for intuitive output formatting.
Assume that a class named Book has been defined, and it has three member variables: a string named title, an int named pages and an int named yearPublished.
The catalog uses the following sorting system: the books are sorted by publishing date. If two books are published in the same year, the longer book is considered "bigger". Finally, if the pages are also the same, the books follow alphabetical order.
Override the ==,< and > operators so that the above-specified order is implemented. The functions have already been declared as follows:
bool operator==(const Book& other) const;
bool operator<(const Book& other) const;
bool operator>(const Book& other) const;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!