[Qt-interest] QSharedDataPointer and forward declared classes
Lukas Geyer
lgeyer at gmx.at
Tue Mar 2 09:04:00 CET 2010
> Why does this work at all? IMHO classes used as template parameters have
> to be fully declared, i.e. not beeing foward declared !?
Okay, it looks like it has to be read "fully declared somewhere". Be
sure the header of the QSharedData subclass is included within the
source of a class using Q(Explicitly)SharedDataPointer and you are fine.
The compiler error was caused by an missing ctor/dtor for TestClass (d'oh!).
> #include <QtCore/QExplicitlySharedDataPointer>
> class TestClassData;
> class TestClass
> {
> private:
> QExplicitlySharedDataPointer<TestClassData> data;
> };
TestClass() and ~TestClass() missing here.
> So, why does this work with Qt's built-in classes and how can i take
> advantage of foward declared template parameters in my own classes?
Have an ctor / dtor in your class an the QSharedData subclass header
included within the source file of your class.
Best,
Lukas.
More information about the Qt-interest-old
mailing list