I am just curious about C++/CLI handle(^) and how it works. For e.g:
The first thing that I cannot understand is, over here the accepted answer says that the caret is the managed equivalent of a * (pointer). However, unlike *, I can directly assign value to ^.
int ^num;
num = 4;
This would not work in C++:
int *num2;
num2 = new int[1];
num2 = 10;
Why is this behavior observed? Also, in Microsoft Webpage they say you cannot point to a member of the object, and it does not support pointer arithmetic. So both the following code snippet would fail to compile
int ^num3 = gcnew int[10];
for(int i = 0; i<10; i++)
%(num3 + i) = i
or
for(int i = 0; i<10; i++)
(num3 + i) = i
Why???
That brings me to final question: What would be equivalent of following int native/normal C++ code snippet in C++/CLI?
int *array1;
array1 = new int[ 10];
for( int i = 0; i < 10; i++)
*(array1 + i ) = i;