Here is a stripped down version of my class setup:
class CMyClass : public CDialog
{
CMyClass(CWnd *pParent = NULL); // constructor
~CMyClass();
_ CBrush *_pRadBkgColor; // background color of a radio button
}
CMyClass::CMyClass(CWnd *pParent /*=NULL*/)
{
// assign CBrush pointer to a new brush
_pRadBkgColor = new CBrush(RGB(0xFF, 0xFF, 0xFF));
}
CMyClass::~CMyClass()
{
if( _pRadBkgColor != NULL )
{
delete _pRadBkgColor
}
_pRadBkgColor = NULL;
}
Now, when I run a tool that parses code for subtle errors, I get this:
new in constructor for class 'Name' which has no assignment operator -- Within a constructor for the cited class, there appeared a new. However, no assignment operator was declared for this class. Presumably some class member (or members) points to dynamically allocated memory. Such memory is not treated properly by the default assignment operator. Normally a custom assignment operator would be needed. Thus, if x and y are both of type Symbol x = y; will result in pointer duplication. A later delete would create chaos.
I believe it's telling me that if I have two member variables that are CBrush pointers, lets call them a and b, and I initialize a with new in my constructor, then later I say b = a (or assign a to any other address really... I guess it'd be best to make that constant), and then I delete a or b, there will be chaos.
If I do no such assignment, is this safe?
Thanks Steven