cannot access private member error when porting MFC project

On the forum, we have surfaced another error. I had a chance today to see a real-world code with this error and actually to narrow down the problem. So if you see an error like

1>c:\program files\microsoft visual studio 8\vc\atlmfc\include\afxwin.h(259) : error C2248: 'CObject::operator =' : cannot access private member declared in class 'CObject'

1> c:\program files\microsoft visual studio 8\vc\atlmfc\include\afx.h(540) : see declaration of 'CObject::operator ='

1> c:\program files\microsoft visual studio 8\vc\atlmfc\include\afx.h(510) : see declaration of 'CObject'

1> This diagnostic occurred in the compiler generated function 'CGdiObject &CGdiObject::operator =(const CGdiObject &)'

The cause of this error is that you are have a class like

class CReproClass {

public:

CReproClass::CReproClass(void) {}

CReproClass::~CReproClass(void) {}

CPen m_pen; //or any other class that subclasses CGdiObject

};

or

class CReproClass : public CPen{

...
};

then is later used inĀ 

CReproClass a;
CReproClass b;
a = b;

This is the cause of the problem.