Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

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
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.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top