quot;error C2248: #39;CObject::CObject#39; : cannot access private member declared in class #39;CObject#39;(quot;错误 C2248: CObject::CObject : 无法访问在类 CObject 中声明的私有成员)
问题描述
可能重复:
使用CArray时出错
重复:使用 CArray 时出错
所以,我正在尝试像这样使用 CArray:
so, i am trying to use CArray like this :
CArray<CPerson,CPerson&> allPersons;
int i=0;
for(int i=0;i<10;i++)
{
allPersons.SetAtGrow(i,CPerson(i));
i++;
}
但是在编译我的程序时,我得到了这个错误:
but when compiling my program, i get this error :
"error C2248: 'CObject::CObject' : cannot access private member declared in class 'CObject' c:program filesmicrosoft visual studio 9.0vcatlmfcincludeafxtempl.h"
我什至不明白这是从哪里来的.
I don't even understand where this is coming from.
帮助!
推荐答案
为你的类 (CPerson) 编写一个构造函数并将其公开.它应该可以解决问题.
Write a constructor for your class (CPerson) and make it public. it should solve the problem.
这篇关于"错误 C2248: 'CObject::CObject' : 无法访问在类 'CObject' 中声明的私有成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:"错误 C2248: 'CObject::CObject' : 无法访问在类 'CObject' 中声明的私有成员
基础教程推荐
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- CString 到 char* 2021-01-01
- 初始化列表*参数*评估顺序 2021-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
