Basically I would like to know the difference between
Int32^ i = gcnew Int32();
and
Int32* i2 = new Int32();
I have written the following code:
#include <stdio.h>
#using <mscorlib.dll>
using namespace System;
int main(void) {
Int32^ i = gcnew Int32();
Int32* i2 = new Int32();
printf("%p %d\n", i2, *i2);
printf("%p %d\n", i, *i);
return 0;
}
It gives the following output:
004158B8 0
00E1002C 0
It seems the two integer are allocated in two different memory locations.
Is the gcnew Int32() allocated in managed heap? or directly on the stack?