gcnew keyword

Apr 23, 2011 at 8:34am
Hi,
I'm studying C++/CLI programming and I have problems with tracking handles. In some examples an object, such as an array, is created using the keyword 'gcnew':
array<int>^ values = gcnew array<int>(5);
In other examples the keyword 'gcnew' is not used:
array<int>^ values = {3, 5, 6, 8, 6};
I have read some articles about it, but none of them explain exactly when the use of 'gcnew' is necessary.
Can anybody explain me?
Thank you.
Apr 23, 2011 at 10:55am
The first one allocates memory for an uninitialized array. The second is the opposite.

joseph63 wrote:
I have read some articles about it, but none of them explain exactly when the use of 'gcnew' is necessary. Can anybody explain me?
You use it when, you allocate memory for an array or a .NET framework object.

Disclaimer:
I'm not a C++/CLI expert. I could be wrong.
Apr 25, 2011 at 5:32pm
OK. Thank you for clarification.
Topic archived. No new replies allowed.