Q3: Define overloading operator Book- (10 points) 3.1In Book class, define opera
ID: 3717619 • Letter: Q
Question
Q3: Define overloading operator Book- (10 points) 3.1In Book class, define operator-overloading function that assigns (copies) one Book object's data members into another book object. So *(ContainerObject1 -> book) - *(ContainerObject2 -> book); will copy ContainerObject1 data members to ContainerObject2 using the operator- overloading function.Explanation / Answer
int Book::operator+(Book *other) { return getNoOfBooks() + other->getNoOfBooks(); } int Book::operator+(int book_count) { return book_count + getNoOfBooks(); } Book &Book::operator=(const Book &other) { name = other.name; noOfbooks = other.noOfbooks; libNumber = other.libNumber; pubDate = other.pubDate; return *this; }
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.