Click here to Skip to main content
11,639,126 members (63,896 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ MFC VC++
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 12-Mar-13 0:22am
Comments
Binu MD at 12-Mar-13 6:57am
   
please tell about the project settings that you were changed.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

This is a protection Smile | :) :
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... Smile | :)

So, for example, the code:
{
  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 Smile | :)
  Permalink  
v2

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

  Print Answers RSS
0 Suvendu Shekhar Giri 280
1 Sergey Alexandrovich Kryukov 279
2 Richard Deeming 200
3 CPallini 187
4 PIEBALDconsult 175
0 OriginalGriff 9,081
1 Sergey Alexandrovich Kryukov 8,812
2 Mika Wendelius 7,027
3 Suvendu Shekhar Giri 2,600
4 F-ES Sitecore 2,548


Advertise | Privacy | Mobile
Web03 | 2.8.150728.1 | Last Updated 12 Mar 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100