我正在尝试返回一个派生自 QObject 的类,但出现以下错误
Error : 'QObject::QObject' : cannot access private member declared in class 'QObject'
这种情况类似于我的情况
头文件:B.h
class B : public QObject
{
Q_OBJECT
private:
...
public:
B(QObject* parent = 0);
...
}
CPP 文件:B.cpp
B:B(QObject *parent)
{
//Empty Constructor
}
头文件:A.h
class A
{
private:
B myClassB;
public :
B ReturnClassB();
}
CPP 文件:C.cpp
B A::ReturnClassB()
{
return myClassB; //This is where the error occurs
}
关于可能出现问题的任何建议?是复制构造函数问题吗?