inheritable d and getting rid of virtual_hook

Thiago Macieira thiago at kde.org
Wed Jun 6 09:40:22 BST 2007


Oswald Buddenhagen said:
> moin,
>
> dfaure and me were pondering the following possibility:
>
> when d is protected (not private), it can be used for adding protected
> virtual methods, too - exactly the purpose of virtual_hook. and it is
> way nicer and less wasteful than the latter.

Indeed. If you take that thought to the extreme, you can move all virtuals
to the Private class.

But that only works for virtuals that aren't supposed to be overridden by
the user of those classes. The users don't have access to the _p.h file,
so they can't override in the d-pointer either.

In the case of classes that have access to the privates anyways, the
change can be done later without breaking BC.

I don't think this replaces the virtual hook in non-QObject classes. Qt
does it too if it matters (see QAbstractFileSystem::extension and
supportsExtension).

-- 
  Thiago Macieira  -  thiago (AT) macieira.info - thiago (AT) kde.org
    PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358






More information about the kde-core-devel mailing list