Click here to Skip to main content
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 1: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 OriginalGriff 6,564
1 Sergey Alexandrovich Kryukov 6,078
2 DamithSL 5,228
3 Manas Bhardwaj 4,717
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web03 | 2.8.1411022.1 | Last Updated 12 Mar 2013
Copyright © CodeProject, 1999-2014
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