5.5. Defining a Derived Class

IThe derived class consists of two parts: the subobject of its base class (consisting of the nonstatic base class data members, if any) and the derived class portion (consisting of the nonstatic derived class data members). (Think of a blue Lego block snapped together with a red one.) This composite nature of the derived class is reflected in its declaration syntax:

// the header file contains the base class definition 
#include "num_sequence.h" 

class Fibonacci : public num_sequence { 
public: 
    // ... 
}; 

The derived class name is followed by a colon, the public keyword, and the name of the base class. [3] The only rule is that the base class definition must be present before a class can inherit from it (this is ...

Get Essential C++ 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.