August 2012
Intermediate to advanced
976 pages
30h 17m
English
A class containing (or inheriting without overridding) a pure virtual function is an abstract base class. An abstract base class defines an interface for subsequent classes to override. We cannot (directly) create objects of a type that is an abstract base class. Because Disc_quote defines net_price as a pure virtual, we cannot define objects of type Disc_quote. We can define objects of classes that inherit from Disc_quote, so long as those classes override net_price:
// Disc_quote declares pure virtual functions, which Bulk_quote will overrideDisc_quote discounted; // error: can't define a Disc_quote objectBulk_quote bulk; // ok: Bulk_quote has no pure virtual functions
Classes that ...
Read now
Unlock full access