Thanks George. So, is there any way for a Native pointer to point to Managed Heap. I know this is not the correct thing to do but is it possible ? An example would be appreciated. I also think there is no way for a Handle (^) to point to native heap, is this correct ?
F
Frank__Q
@Frank__Q
Posts
-
Where is this managed object stored? -
Where is this managed object stored?value class ValBase
{
public:
int a;
};ref class RefBase
{
public:
int a;
};int main(array ^args)
{RefBase^ RefBase1 = gcnew RefBase; //LEGAL. Ref type Managed Obj created on CLR heap.
ValBase^ ValBase1 = gcnew ValBase; //LEGAL. Value type Managed Obj created on CLR heap.RefBase* RefBase2 = new RefBase; //ILLEGAL: new cannot be used on Managed Ref Class
ValBase* ValBase2 = new ValBase; //This compiles okay but where is this "Managed Object" stored ? CLR heap or Native heap ?}
In the last assignment where is the managed object stored ? I am totally new to C++ CLI. Also, is it true that value types should use stack semantics to make code efficient ? i.e instead of ValBase^ ValBase1 = gcnew ValBase, I should just use ValBase ValBase1;