I have a class that has some data members that I want to be hidden from the caller (because including the headers for their types significantly increases the compile time, and it would require every project using this class to add an additional path to their include paths).
This class uses QSharedDataPointer
to store this data. This way it can be copied by using the default copy constructor.
The basic structure of this class is:
class MyClass {
private:
QSharedDataPointer<MySharedClassData> m_data;
};
Is there any fancy trick to do this without defining MySharedClassData
(which inherits from QSharedData
) in the same header file? Or is there any other good way of hiding data fields?
I've already tried a forward declaration of MySharedClassData
but this didn't work (despite the fact that m_data
is private
).
The only solution I can currently thing of is to declare m_data
as QSharedDataPointer<QSharedData>
but then I need to cast the data member every time I want to access it. Is there a better solution?