Expert C Programming

(Jeff_L) #1

  • has no definition in the base class that declares it, but will be defined later in a
    derived class,

  • that (refering to the derived class) shares the multiply inherited base

  • which (refering to the base class) is inherited in a protected way.


And the last time we needed one was...well, we haven't yet! Does this start to remind
anyone of the program proof of the Fast Fourier Transform? It certainly ranks alongside it
in complexity.

In C++ code, this might look like:

class vbc {


protected: virtual void v()=0;


private: virtual ~vbc()=0; // private destructor


};


// vbc is an abstract class because it contains pure


virtual functions


classX:virtual protected vbc {


// X inherits vbc virtually, and does it in a way such


that


// vbc's protected members are protected members of X.


// So vbc is a "protected abstract virtual base" class


of X.


protected: void v() {}


~X() { / do some X destruction / }


};


// When an X object is destroyed, X::~X is called, and


then...


// X's "protected abstract virtual base pure virtual


private destructor"


// is called too. So even though it's declared pure, it


must be defined.


These are the kind of semantics that gives C++ a reputation for being overly complicated.
The problem is not any one feature, but rather the complexity of how all the different
features interact. We'll stop at this point, and allow the reader to form his or her own
conclusions.

Some Light Relief—The Dead Computers Society


There are many and varied computer-related organizations, but the prize for most unusual surely goes
to The Dead Computers Society!

Free download pdf