> are managed arrays of value types created on the managed heap, just as are
managed arrays of reference types ?
yep. Everything is created on the managed heap.
String* StrArray[] = new String* [5]; // Arrays of a Reference type
int NumArray __gc[] = new int __gc[5]; // // Arrays of a Value type
So both 'StrArray' and 'NumArray' are located on the heap ? and the only
difference is that 'StrArray' contains pointers to String, and 'NumArray'
contains its values directly.
Is that correct ?
Not entirely since you don't have real pointers as you're used to in
native c++; rather StrArray contains handles to the gc-controlled
memory. You can think of an handle as a pointer to a lookuptable that
contains the real memory address. This is important since the memory
location of your objects doesn't neccessary stay constant (the gc moves
objects around as it compacts the heap). If you want to pass managed
objects to unmanaged code, you have to make sure the gc doesn't move
things around by pinning the objects (using __pin).
In the next version of managed c++ (download the beta at
lab.msdn.microsoft.com/vs2005) this difference between pointers and
handles is also reprsented in the syntax. Instead of String* you would
then write String^.
I hope what I'm saying here is correct :)
--
Ben
http://bschwehn.de