August 2012
Intermediate to advanced
976 pages
30h 17m
English
Basket ClassOne of the ironies of object-oriented programming in C++ is that we cannot use objects directly to support it. Instead, we must use pointers and references. Because pointers impose complexity on our programs, we often define auxiliary classes to help manage that complexity. We’ll start by defining a class to represent a basket:
class Basket {public: // Basket uses synthesized default constructor and copy-control members void add_item(const std::shared_ptr<Quote> &sale) { items.insert(sale); } // prints the total price for each book and the overall total for all items in the basket double total_receipt(std::ostream&) ...
Read now
Unlock full access