I am trying to setup parameter from one class into another.
But for types CDC and CBitmap, it won’t let me??
dcMem and m_bmp are instance variables or the parameters in the class
(also note that I am using vc++ 6.0)
error C2582: 'CDC' : 'operator =' function is unavailable
error C2582: 'CBitmap' : 'operator =' function is unavailable
.
Image::Set_dcMem(CDC _dcMem)
{
dcMem = _dcMem;
}
.
Image::Set_m_bmp(CBitmap _m_bmp)
{
m_bmp = _m_bmp;
}
I had also tried just setting the parameters as such from the other class but got the same errors listed above:
Image *pImage = new Image;
pImage->dcMem = dcMem;
pImage->m_bmp = m_bmp;
I found this links, but not sure how to apply:
http://msdn.microsoft.com/en-us/library/ccb3dh5c%28v=vs.80%29.aspx
http://msdn.microsoft.com/en-us/library/aa983787%28v=vs.71%29.aspx
with the correction from down below:
CDC* dcMem;
CBitmap *m_bmp;
Image *pImage = new Image;
pImage->dcMem = &dcMem;
pImage->m_bmp = &m_bmp;
When you assign an object using
=the object is copied, the variable on the left is already instantiated, so it must somehow get a copy of the state of the object on the right side of the assignment.But sometimes it is difficult to copy an object. In some cases it is because some of the internal data members of the object cannot be copied, or because it is difficult or time consuming to copy them.
In any case, when the author of a class decides that copies will not work for that class, he/she undefines the
operator=method, to prevent users of the class from ever trying to assign objects of that class. See this question for some additional information on this.But this isn’t a huge problem. Normally, for objects of this kind you don’t really want to be happily triggering copies of objects anyway. Instead, what you want to do is work with references and pointers.