One may extend a class definition by declaring a new class (the ``derived class'') that inherits from the old class (the ``base class'').
class base {
public:
int bi;
inline void setBi(int val) {bi = val}
};
class inh: public base { // inh inherits from base
public:
int ii;
};
inh *p; // p is a pointer to an object of type inh
p = new inh; // a new object of type inh is created
p->ii = 1;
p->setBi(4); // the inh object inherited a bi and setBi()
// from base
The line
class inh: public base {
means that inh is a new type of class, and that it inherits from the class base. The keyword public means that anything that was public in base will also be public in inh. It would also be possible to do a private inheritance, so that even the public members of base would be private in inh.