Thread: C++ objects behave upon assignment

  1. #1
    Registered User
    Join Date
    Jul 2011

    C++ objects behave upon assignment

    I am trying to understand how C++ object behave in the following case.

    I declare a handle using windows HDC as follows: HDC myHDC.

    version 1:
    My function is delcared as follows:
    BMManager::BMManager(HDC _hdc) {
    version 2:
    BMManager::BMManager(HDC &_hdc) {
    In both version, the declaration for myHDC remains the same. The compiler did not complain on any error.
    Question1: Why would myHDC by treated differently between version 1 and version 2? After all, upon assignment the object declared remains the same.

    I would assume that version 1 says that is copy assignment, so all values in HDC is copyied. Perhaps handles are not object?????
    In version 2, myHDC points to an address of _hdc????

  2. #2
    train spotter
    Join Date
    Aug 2001
    near a computer
    A HDC is of type 'void pointer' [void* ] and not an object (as are all HANDLE variables).
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. SetTimer() doesn't behave.
    By OnionKnight in forum Windows Programming
    Replies: 9
    Last Post: 04-09-2007, 03:52 PM
  2. OpenGL - Lights behave strangely
    By Frobozz in forum Game Programming
    Replies: 5
    Last Post: 06-06-2004, 02:00 PM
  3. Why does it behave so
    By mudigonda_ms in forum C Programming
    Replies: 6
    Last Post: 12-21-2003, 01:54 AM
  4. Two Struct & Class Programs that behave the same
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 07-05-2002, 09:59 AM
  5. Why the function behave like that?
    By zahid in forum C Programming
    Replies: 1
    Last Post: 12-21-2001, 06:56 AM