Boost logo

Boost :

From: Daniel Frey (daniel.frey_at_[hidden])
Date: 2002-02-13 09:54:43

Hello, world!

I searched the messages of the boost-group but couldn't find any
reference to 'final'. If it was discussed before, please gently point me
to the right message :)

By 'final', I mean a way to mark a class 'final' like in Java to prevent
others from deriving from that class. A simple solution of this is
something like this:

   template< typename T > class finalize
      friend T;
      finalize() {}

   class A : public virtual finalize< A > { ... };
   class B : public A { ... };


   A(); // OK
   B(); // Compile-time error

This can probably be made easier by a #define for the user, but these
are all details. Generally, I'd like to know if it makes sense at all.
Is there any need for 'final' in C++ or is it a design-problem of my
class / application if I think I should mark a class 'final'? Does the
approach above yield any problems I haven't seen yet? Is there a better
way? Or is it a useful idea to be added to... say...

Regards, Daniel

Daniel Frey
aixigo AG - financial training, research and technology
Schloß-Rahe-Straße 15, 52072 Aachen, Germany
fon: +49 (0)241 936737-42, fax: +49 (0)241 936737-99
eMail: daniel.frey_at_[hidden], web:

Boost list run by bdawes at, gregod at, cpdaniel at, john at