I'd mentioned that MC++ provides mode control over boxing and unboxing than C#. Here's an example of directly modifying boxed value types on the heap, without unboxing & reboxing them or resorting to adjustor interfaces: <a href="//">// HeapMod.cpp: cl.exe /clr HeapMod.cpp #using using namespace System; __value struct Universe { int Answer; }; void main() { Universe u; Object* po = __box(u); Universe* pu = __try_cast(po); pu->Answer = 42; Universe* pu2 = __try_cast(po); Console::WriteLine(pu2->Answer); }
[Peter Drayton's Radio Weblog]
Thans Peter for doing my work for me again-). I should be doing this as the author of a Managed C++ book, but there is so little time (especially when my wife wants to get my off the computer so much that she hides my keyboard! -))
8:54:33 AM
|