Using Qt 4.7.1
Looking at the QFile implementation it appears that all member variables are stored in a class QFilePrivate which does not provide any form of encapsulation.
What benefit does the separation of methods and variables provide? Is this a design pattern?
To access the instance of QFilePrivate the QFile uses the "d" pointer. An example "d->fileName.IsEmpty()". Where is the pointer "d" defined?
It is mostly the case in Qt framework with private classes. It is just to make end class look pretty for developers. pointer *d is always defined in private section of its end class. The private class itself is predefined in header, right before end class.
and declared in .cpp file.
or just in separate private header and source files which you can find under src/ folder and not in include/ folder.
It is actually nice design pattern, helps make code clear in big projects and hide simple and conventional code which will mostly never changed in separate classes...
"What is the d-pointer":http://qt-project.org/wiki/Dpointer
Thought "this":http://zchydem.enume.net/2010/01/19/qt-howto-private-classes-and-d-pointers/ and "this":http://techbase.kde.org/Policies/Binary_Compatibility_Issues_With_C++#Definition article described the issue nicely.
Actually, it provides very strong encapsulation. You cannot access the d pointer as a user of the API, which is the whole point of encapsulation.