cannot understand OOP code

Status
Not open for further replies.

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
Visit site
Activity points
5,134
hello every one


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
 

this is is a graphic buffer , which contains a bitmap for showing and saving
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…