A Derived Class Constructor Initializes Its Direct Base Class Only

Now we can reimplement Bulk_quote to inherit from Disc_quote rather than inheriting directly from Quote:

// the discount kicks in when a specified number of copies of the same book are sold// the discount is expressed as a fraction to use to reduce the normal priceclass Bulk_quote : public Disc_quote {public:    Bulk_quote() = default;    Bulk_quote(const std::string& book, double price,              std::size_t qty, double disc):          Disc_quote(book, price, qty, disc) { }    // overrides the base version to implement the bulk purchase discount policy    double net_price(std::size_t) const override;};

This version of Bulk_quote has a direct base class, Disc_quote, and an ...

Get C++ Primer, Fifth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.