Couple of questions on Handles

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jack

    Couple of questions on Handles

    So I am learning c++/cli and I have a couple of questions about
    handles. From what I understand these two are pretty similar except
    that handles point to Managed Heap and Pointer point to the native
    heap. My question is in the following code where is the handle
    pointing to?

    int^ handle = 5;

    is this on the managed heap? and what is the diff between the above
    and this:

    int^ handle = gcnew int;
    handle = 5;

    Are they both the same? if so then what is the point of using the
    gcnew keyword. Also does a handle (similar to a pointer) holds the
    memory address of the item? If so then why can't u do something like
    this?

    int a = 6;
    int^ handle = &a;

    and lastly, since we can use things like realloc and calloc in C, are
    their similar functions for handles?

    Thanks
    Jack
Working...