This will not work. Non-virtual base classes are always initialized by a class that is immediately derived from them. That is, if the script looks like this:
class Final : public MakeFinal { public: Final() {} }; class Derived : public Final {};
then ctor Derived only initializes Final , which is fine ( Final has a public ctor). Final ctor then initializes the MakeFinal , which is also possible since Final is a friend.
However, the rule is different for virtual base classes. All virtual base classes are initialized by the ctor of the derived object itself. That is, when creating an instance of Final , it has Final ctor that initializes the MakeFinal . However, when trying to create an instance of Derived it must be the Derived ctor that initializes the MakeFinal . And this is not possible due to MakeFinal private ctor.
Also note that C ++ 11 introduced the Final keyword for classes (and virtual functions).
source share