繁体   English   中英

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

[英]VS2013 compiler: 'CObject::CObject' : cannot access private member declared in class 'CObject'

我正在尝试将项目从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的定义似乎也没有改变,这使得它变得陌生。

这里还报告了其他类似的问题,但是我在那里找不到我的问题的解决方案。 在大多数其他情况下,问题似乎是由于缺少公共默认构造函数,Copy构造函数或赋值运算符引起的。

但是,扩展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);
}

任何帮助,将不胜感激。

PS我们的实现已导出到DLL,我想知道这是否会引起一些冲突?

编辑:不是重复使用CArray错误使用CArray的 错误 ->在这些CObject派生类中缺少公共默认值和副本构造函数。 如上所述,我们的代码并非如此。

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

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

另一种选择是使用std容器而不是CList。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM