Thread: reference and handle

  1. #1
    Registered User
    Join Date
    Apr 2005
    Posts
    1

    Question reference and handle

    what is the difference between a handle and reference(pointer) to a variable or object

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    A pointer is just a variable that holds a memory address. A handle is a pointer to a pointer. I'm sure you understand the benefits of pointers, but handles are used quite a lot in Windows programming. When you have a complex GUI, the OS may need to move around large chunks of memory often. If your program has a pointer to one of these chunks that gets moved, the value of that pointer suddenly changes, which can cause problems for your program. That's why handles are used. The handle consistently points to one pointer, and that pointer will then point to wherever the memory is. Hope that helps.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. [Linker error] undefined reference to `GetStockObject@4'
    By NecroFromHell in forum Windows Programming
    Replies: 7
    Last Post: 10-07-2010, 04:27 AM
  2. Undefined Reference to...
    By JJFMJR in forum C++ Programming
    Replies: 3
    Last Post: 08-16-2008, 03:09 AM
  3. Managed C++, passing arguments by reference
    By jimzy in forum C++ Programming
    Replies: 8
    Last Post: 11-02-2007, 01:03 PM
  4. Direct3D problem
    By cboard_member in forum Game Programming
    Replies: 10
    Last Post: 04-09-2006, 03:36 AM
  5. Manipulating the Windows Clipboard
    By Johno in forum Windows Programming
    Replies: 2
    Last Post: 10-01-2002, 09:37 AM