Browse - Programming Tips - What is causing this error when I compile my program:
Product: Visual C++
Q. What is causing this error when I compile my program:
c:\program files (x86)\microsoft visual studio 8\vc\atlmfc\include\afxwin.h(1820) : error C2248: 'CObject::CObject' : cannot access private member declared in class 'CObject'
1> c:\program files (x86)\microsoft visual studio 8\vc\atlmfc\include\afx.h(558) : see declaration of 'CObject::CObject'
1> c:\program files (x86)\microsoft visual studio 8\vc\atlmfc\include\afx.h(529) : see declaration of 'CObject'
1> This diagnostic occurred in the compiler generated function 'CCmdTarget::CCmdTarget(const CCmdTarget &)'
A. You are trying to access the copy constructor of something that doesn't
want to you. Its probably a MFC class or a class you made that extends a MFC class. Here is some code that caused it for me:
class MyCustomClass : CWnd
// Attempting to return a reference to a class based on CWnd doesn't work
// This way works
MyCustomClass custom = something.GetCustomClassReference();