[Development] final value classes: some background information and plans

andre.poenitz at nokia.com andre.poenitz at nokia.com
Wed Mar 7 12:55:41 CET 2012


> Marc Mutz [marc.mutz at kdab.com]
> > Marc Mutz wote:
> > > I've uploaded a patch series that makes most of the value classes in
> > > QtCore final in the C++11 sense (ie. under a C++11 compiler, these can no
> > > longer be inherited from).
> >
> > I disagree with the idea of making Qt core classes non-inheritable.
> >
> > While inheritance from "value" classes is rarely needed, it _is_ useful at
> > times. Most notably, private inheritance is even "pretty safe".
> >
> > There is no need to artificially deprive us of useful tools.
>
> Name one instance where (non-public, since public isn't safe) inheritance is
> useful and not just laziness on the part of the inheriter :)

Lazyness _is_ a good reason. 

Qt is meant to be _useful_.

Having to write forwarding functions to a say, QString, member is way more
tedious than at 'using Base::...', and less error prone. 

I have seen code like 

   int Derived::foo(int x, int c, int a, int v, int u, int w, int i, int j, int l)  { data.foo(x, c, a, u, v, w, i, l); }

in practice. Even if a compiler might issue warn for some of the issues, there is no need
to force people to have to use this kind of code.

So: Please not.

Andre'



More information about the Development mailing list