26.7 Case Study: Putting Patterns to Work (cont.)
Derived classes implement the virtual functions
get_total_price
is defined in the
Item
class:
double Item::get_total_price() const { return get_quantity() * get_unit_price(); }
A generic item can't compute quantity or unit price, but it knows that the total price is their product - TEMPLATE METHOD pattern
prev
|
top
|
next