syedshan
Advanced Member level 1
- Joined
- Feb 27, 2012
- Messages
- 463
- Helped
- 27
- Reputation
- 54
- Reaction score
- 26
- Trophy points
- 1,308
- Location
- Jeonju, South Korea
- Activity points
- 5,134
hello every one
please see the code below. I cannot understand the following
and following
The whole code for the class is as below.
thanks in advance
please see the code below. I cannot understand the following
Code:
Bitmap () : _hBitmap (0) {}
and following
Code:
void operator = (Bitmap & bmp)
{
if (bmp._hBitmap != _hBitmap)
{
Free ();
_hBitmap = bmp.Release ();
}
}
The whole code for the class is as below.
Code:
class Bitmap
{
public:
Bitmap () : _hBitmap (0) {}
// Transfer semantics
Bitmap (Bitmap & bmp)
: _hBitmap (bmp.Release ())
{}
void operator = (Bitmap & bmp)
{
if (bmp._hBitmap != _hBitmap)
{
Free ();
_hBitmap = bmp.Release ();
}
}
HBITMAP Release ()
{
HBITMAP h = _hBitmap;
_hBitmap = 0;
return h;
}
~Bitmap ()
{
Free ();
}
// implicit conversion for use with Windows API
operator HBITMAP () { return _hBitmap; }
protected:
Bitmap (HBITMAP hBitmap)
: _hBitmap (hBitmap)
{}
void Free ()
{
if (_hBitmap)
::DeleteObject (_hBitmap);
}
HBITMAP _hBitmap;
};
thanks in advance