Stupid Question 126: What is a hat type or handle declarator in C++/CX?
What is a hat type?
So a first question, which fits very nicely with the previous (but still ongoing, pointer series some questions: What is a pointer?) is what is a hat type in C++/CX?
Example: ArrayList ^ arr = gcnew ArrayList();
The ^ actually indicates a managed pointer. What it does is that it declares a handle to an object on the managed heap, it used to be _gc but the hat ^ (the handle declarator) has replaced it. It points to the whole object , and you cannot do pointer arithmetic, but on the other hand it gives you type conversion capabilities. You should use the gcnew keyword which creates a new instance of a managed type so it will automatically be garbage collected.
Last modified on 2013-01-13