What to do about dpointers
winter at kde.org
Fri May 18 14:19:29 BST 2007
On Friday 18 May 2007 7:37:34 am David Faure wrote:
> On Friday 18 May 2007, Andreas Pakulat wrote:
> > Hi,
> > I'd like to know what do you kdelibs people do wrt to classes that don't
> > have private members (at the moment) and no dpointer? Do you add a
> > dpointer and private class and just initialize the dpointer to 0? Whats
> > the common practice for this?
> Assuming this is about exported and installed classes only,
> the common practice would be to add a d pointer and move all member vars
> into it (the krazy check warns about a lack of d pointers, but also about member
> variables). Exceptions would be if some public method needs to be inline for
> speed reasons but that's probably not the case in kdelibs (as it is in e.g. QString).
But, even if your class doesn't have any private members it is still
good practice to give it a const dpointer and initialize it to 0.
More information about the kde-core-devel