/***************************************************************************** *** FILE: marray.cpp *** DATE: 04/10/2004 *** AUTHOR: Daniel Dementiev *** GOAL: This short example illustrates how to create managed multi *** dimensional array is MS Visual C++ managed extension. Please note *** how we use properties and methods inherited from Array class. *** To compile the project, use *** ...> cl marray.cpp /clr *****************************************************************************/ #using using namespace System; __gc class Robot { private: static int curID = 1; int ID; int HP; public: Robot() : ID(curID++), HP(100) { Console::WriteLine( String::Concat(S"Robot ", ID.ToString(), S" created") ); }; ~Robot() { Console::WriteLine( String::Concat(S"Robot ", ID.ToString(), S" destroyed") ); } }; void main() { int N = 5, M = 3, i; Robot* robots[,] = __gc new Robot*[N, M]; for(i=0;iLength.ToString()); Console::WriteLine(S"IsFixedSize = {0}", robots->IsFixedSize.ToString()); Console::WriteLine(S"Rank = {0}", robots->Rank.ToString()); for(i=0;iRank;i++) Console::WriteLine(S"Dimension #{0}: lower bound:{1} upper bound: {2}", i.ToString(), robots->GetLowerBound(i).ToString(), robots->GetUpperBound(i).ToString() ); }