Stopping inheritance?

Those of you familiar with Java are likely familiar with the keyword final, use to stop a class from being inherited. C++11 adds final.

  • You could have used private constructors to block inheritance.

Here goes the example from the textbook ...

class NoDerive final {};

class Base {};

class Last final : Base {};

class Bad : NoDerive {};

class Bad2 : Last {};