
下面是QScopedPointer官网介绍:
只要在 QScopedPointer 需要清理时,正向声明类的析构函数可用,就可以在 QScopedPointer 中使用正向声明的类。
具体而言,这意味着所有包含指向正向声明类的 QScopedPointer 的类都必须具有非内联构造函数、析构函数和赋值运算符
class MyPrivateClass; // forward declare MyPrivateClass
class MyClass
{
private:
QScopedPointer privatePtr; // QScopedPointer to forward declared class
public:
MyClass(); // OK
inline ~MyClass() {} // VIOLATION - Destructor must not be inline
private:
Q_DISABLE_COPY(MyClass) // OK - copy constructor and assignment operators
// are now disabled, so the compiler won't implicitely
// generate them.
};