简体   繁体   English

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

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

I'm trying to migrate a project from to c++11 in Visual Studio. 我正在尝试将项目从Visual Studio迁移到c ++ 11。 I fixed a number of issues, but there's one remaining which I can't seem to crack with MFC: 我修复了许多问题,但还有一个我似乎无法用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 &> &)'

This is code that hasn't changed on our end and has been compiling fine when targeting the Visual Studio 2010 toolset. 这是我们最后未更改的代码,在针对Visual Studio 2010工具集时可以很好地进行编译。 From what I could gather it doesn't seem like the definition of CObject has changed either which makes it all the stranger. 据我所知,CObject的定义似乎也没有改变,这使得它变得陌生。

There's other similar questions reported here, but I couldn't find a solution to my problem there. 这里还报告了其他类似的问题,但是我在那里找不到我的问题的解决方案。 In most other cases it would appear the issue comes from a lack of public default constructors, Copy constructors, or assignment operators. 在大多数其他情况下,问题似乎是由于缺少公共默认构造函数,Copy构造函数或赋值运算符引起的。

Our class that extends CList however provides public versions of all these, and ParameterValue does not inherit from 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);
}

Any help would be appreciated. 任何帮助,将不胜感激。

PSOur implementation is exported into a DLL, I'm wondering if that might be causing some conflicts? PS我们的实现已导出到DLL,我想知道这是否会引起一些冲突?

Edit: Not a duplicate of error using CArray or error using CArray -> in these the CObject derived classes were missing public default and copy constructors. 编辑:不是重复使用CArray错误使用CArray的 错误 ->在这些CObject派生类中缺少公共默认值和副本构造函数。 As described above, this is not the case with our code. 如上所述,我们的代码并非如此。

I think the problem is in your ParameterValue class. 我认为问题出在您的ParameterValue类中。 Try to declare public constructors in there, including the default constructor. 尝试在其中声明公共构造函数,包括默认构造函数。 It seems to me that the CList tries to call the ParameterValue constructor somewhere, but the former can't because the latter is private. 在我看来,CList试图在某个地方调用ParameterValue构造函数,但是前者不能,因为后者是私有的。

Alternatively, try to use a List of Pointers, like CList<ParameterValue*, ParameterValue*&> . 或者,尝试使用指针列表,例如CList<ParameterValue*, ParameterValue*&>

Another alternative is to use a std container instead of CList. 另一种选择是使用std容器而不是CList。

暂无
暂无

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

相关问题 &#39;CObject :: CObject&#39;:无法访问在类&#39;CObject&#39;中声明的私有成员 - 'CObject::CObject' : cannot access private member declared in class 'CObject' 无法访问在类“ CObject”中声明的私有成员 - Cannot access private member declared in class 'CObject' 无法访问在类“ CObject”中声明的私有成员? - Cannot access private member declared in class 'CObject'? 错误C2248:'CObject :: CObject':无法访问类'CObject'afxwin.h中声明的私有成员 - error C2248: 'CObject::CObject' : cannot access private member declared in class 'CObject' afxwin.h CPtrList 无法使用:错误 C2248:“CObject::operator =”:无法访问类“CObject”中声明的私有成员 - CPtrList cannot use: error C2248: 'CObject::operator =' : cannot access private member declared in class 'CObject' 使用CArray时出错:无法访问在类CObject中声明的私有成员 - Error using CArray: cannot access private member declared in class CObject &#39;CObject :: CObject&#39;:无法访问在&#39;CObject&#39;d:\\ Program Files \\ Microsoft Visual Studio 9.0 \\ vc \\ atlmfc \\ include \\ afxcoll.h中声明的私有成员 - 'CObject::CObject' : cannot access private member declared in class 'CObject'd:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxcoll.h 错误 C2248: 'CObject::CObject': 当我在 ZD7421054471AB272ZCEAC18FD97BBD237 - error C2248: 'CObject::CObject' : cannot access private member declared in class 'CObject' when I calling hDC.SelectObject function in MFC 试图传递CStringArray给出错误无法访问类'CObject'中声明的私有成员 - Trying to pass a CStringArray gives error cannot access private member declared in class 'CObject' 向CArray添加数据会产生错误“无法访问在类&#39;CObject&#39;中声明的私有成员” - Adding data to CArray gives error “cannot access private member declared in class 'CObject'”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM