VS2013编译器:' CObject :: CObject' :无法访问类中声明的私有成员' CObject'

时间:2015-06-19 15:45:37

标签: c++ c++11 mfc

我试图在Visual Studio中将项目迁移到c ++ 11。我解决了很多问题,但还有一个问题,我似乎无法用MFC破解:

error C2248: 'CObject::CObject' : cannot access private member declared in class 'CObject' (file.cpp)
: see declaration of 'CObject::CObject'
: see declaration of 'CObject'
This diagnostic occurred in the compiler generated function 'CList<ParameterValue,ParameterValue &>::CList(const CList<ParameterValue,ParameterValue &> &)'

这是我们最终没有改变的代码,并且在定位Visual Studio 2010工具集时编译得很好。从我可以收集到的内容来看,CObject的定义似乎没有改变,这使得它变得更加陌生。

此处还报告了其他类似问题,但我无法找到解决问题的方法。在大多数其他情况下,问题似乎来自缺少公共默认构造函数,复制构造函数或赋值运算符。

我们扩展CList的类会提供所有这些的公共版本,而ParameterValue不会从CObject继承。

class __declspec(dllexport) GParameterValueList : public CList<ParameterValue, ParameterValue&>
{
// ParameterValue is a struct that DOES NOT inherit from CObject (or anything)
public:
    GParameterValueList();
    GParameterValueList(const GParameterValueList& SrcList);
    GParameterValueList& operator=(const GParameterValueList& SrcList);
}

任何帮助都将不胜感激。

P.S.Our实现被导出到DLL中,我想知道这是否会导致一些冲突?

修改:不是error using CArrayerror using CArray的重复 - &gt;在这些CObject派生类中缺少公共默认和复制构造函数。如上所述,我们的代码不是这种情况。

1 个答案:

答案 0 :(得分:0)

我认为问题出在您的ParameterValue类中。尝试在那里声明 public 构造函数,包括默认构造函数。 在我看来,CList试图在某处调用ParameterValue构造函数,但前者不能,因为后者是私有的。

或者,尝试使用指针列表,例如CList<ParameterValue*, ParameterValue*&>

另一种方法是使用std容器而不是CList。

相关问题