Multidimension arrays
-
Multidimension arrays Read dozens of examples given on website how to do an single array with the System::Array etc. But I can't get the hang of it how to use it properly. I keep getting error messages when I hit the build button. For example I want a simple 2 dimension array of the integer type. in the old code it was: int board[16][16]; board[3][3] = 5; if i try to use the managed version: array^ m_Board = gcnew array(16,16); for (int row = 0; row < 16;row++) { for (int col = 0; col < 16;col++) { m_Board[row][col] = 0; } } :confused: I get error message on my screen. Also I can't find anything about freeing the memory in the articles. Is it neccessary if you use it in a class. How do I free it if it's necessary? Can I change the size of the area dynamically? "Knowledge shouldn't be preserved by one, but shared with others." -- Preminition
-
Multidimension arrays Read dozens of examples given on website how to do an single array with the System::Array etc. But I can't get the hang of it how to use it properly. I keep getting error messages when I hit the build button. For example I want a simple 2 dimension array of the integer type. in the old code it was: int board[16][16]; board[3][3] = 5; if i try to use the managed version: array^ m_Board = gcnew array(16,16); for (int row = 0; row < 16;row++) { for (int col = 0; col < 16;col++) { m_Board[row][col] = 0; } } :confused: I get error message on my screen. Also I can't find anything about freeing the memory in the articles. Is it neccessary if you use it in a class. How do I free it if it's necessary? Can I change the size of the area dynamically? "Knowledge shouldn't be preserved by one, but shared with others." -- Preminition
That should be
array<int,2>
notarray<int^,2>
since you want the array to containint
s.--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ VB > soccer
-
Multidimension arrays Read dozens of examples given on website how to do an single array with the System::Array etc. But I can't get the hang of it how to use it properly. I keep getting error messages when I hit the build button. For example I want a simple 2 dimension array of the integer type. in the old code it was: int board[16][16]; board[3][3] = 5; if i try to use the managed version: array^ m_Board = gcnew array(16,16); for (int row = 0; row < 16;row++) { for (int col = 0; col < 16;col++) { m_Board[row][col] = 0; } } :confused: I get error message on my screen. Also I can't find anything about freeing the memory in the articles. Is it neccessary if you use it in a class. How do I free it if it's necessary? Can I change the size of the area dynamically? "Knowledge shouldn't be preserved by one, but shared with others." -- Preminition