A virtual
base class is initialized by the single most derived class' constructor's member initializer list.
Because the virtual
base can be a common base-class object for multiple derived classes, and the initializations specified by those derived classes can conflict.
The initialization specification in the most derived class acts conceptually as if the most derived class was derived directly from the virtual
base class, i.e.
FinalUser(void) {};
… is equivalent to
FinalUser(): MakeFinal() {}
Since the MakeFinal
constructor is protected
, it's available to all derived classes.
That includes that it's available to class FinalUser
.
In other news:
The names in this code indicate that it's about using a C++03 trick for creating a class that can't be (usefully) derived from, a “final” class. The trick is essentially to have a class template that can act as most derived class and that has the necessary friend
-ship to access the for other classes inaccessible constructor of the virtual
base class. C++11 introduced the keyword final
to do that more easily, and without the overhead of virtual
inheritance.