Click here to Skip to main content
15,441,149 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi to all. I have been trying to debug an application but it is giving me error only in debug
build. release build works fine. do i need to change some project settings or exclude some dlls?
i get the following debug output message in output window.

C:\Program Files\Microsoft Visual Studio 10.0\VC\atlmfc\include\afxtempl.h(262): error
C2248: 'CObject::CObject' : cannot access private member declared in class 'CObject'

C:\Program Files\Microsoft Visual Studio 10.0\VC\atlmfc\include\afx.h(535) : see
declaration of 'CObject::CObject'

C:\Program Files\Microsoft Visual Studio 10.0\VC\atlmfc\include\afx.h(510) : see
declaration of 'CObject'

This diagnostic occurred in the compiler generated function
'CArray<type,arg_type>::CArray(const CArray<type,arg_type> &)'
with
[
TYPE=CString,
ARG_TYPE=CString
]
Posted
Comments
Binu MD 12-Mar-13 6:57am    
please tell about the project settings that you were changed.

1 solution

This is a protection :) :
C++
private:
    CObject(const CObject& objectSrc);              // no implementation

...while the CArray class has not a copy constructor.

Why is it a "protection" ?
CArray do not know how its members must be copied, and CObject (base) as well... :)

So, for example, the code:
C++
{
  CArray<CString>* pArray(new CArray<CString>);
  pArray->Add(_T("One"));
  pArray->Add(_T("Two"));

  CArray<CString> arTest(*pArray);

  delete pArray;
  pArray = NULL;

  TCHAR tchTest(arTest[0].GetAt(1) + arTest[1].GetAt(2));
}

... may provide a crash at its last line :)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900