【发布时间】:2015-01-19 01:29:35
【问题描述】:
我收到一个奇怪的错误,告诉我我无法访问在类“CObject”中声明的私有成员,而只是尝试将 CStringArray 传递给我编写的将其分解为多个部分的函数。 我已经注释掉了我的整个函数代码,所以我知道问题存在于对象本身的传递中,我假设我这样做不正确。
这是我的代码:
// If successful, read file into CStringArray
CString strLine;
CStringArray lines;
while (theFile.ReadString(strLine))
{
lines.Add(strLine);
}
// Close the file, don't need it anymore
theFile.Close();
// Break up the string array and separate it into data
CStringArrayHandler(lines);
这是我的 CStringArrayHandler 函数:
void CSDI1View::CStringArrayHandler(CStringArray arr)
{
// Left out code here since it is not the cause of the problem
}
这是我的头文件中函数的声明:
class CSDI1View : public CView
{
// Operations
public:
void CStringArrayHandler(CStringArray arr); // <<<<===================
这是我得到的错误的全文:
错误 1 错误 C2248:“CObject::CObject”:无法访问在类中声明的私有成员 >“CObject”c:\program files (x86)\microsoft visual studio 12.0\vc\atlmfc\include\afxcoll.h 590 1 >SDI-1
【问题讨论】:
-
尝试通过引用将数组传递给 CStringArrayHandler。
标签: c++ visual-studio-2013 mfc compiler-errors cstring