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 override
Disc_quote discounted; // error: can't define a Disc_quote object
Bulk_quote bulk; // ok: Bulk_quote has no pure virtual functions
Classes that inherit from Disc_quote
must define net_price
or those classes will be abstract as well.