View Single Post
Old 03-29-2005, 03:49 PM   #2 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
This is how you could set up a basic matrix. Observe the very details!
Code:
#include <iostream>

using namespace std;

//--

int main()
{
  int** Matrix;
  unsigned nRows(3);
  unsigned nCols(4);
  
  Matrix = new int*[nRows];
  
  if (Matrix != 0) 
  { 
    for(unsigned i = 0; i < nRows; ++i) 
    { 
      Matrix[i] = new int[nCols]; 
    }
  }
  
  //Let's see how we delete them. Watch closely.
  for(unsigned i = 0; i < nRows; ++i) 
  { 
    delete[] Matrix[i]; 
  } 
  delete[] Matrix;
  
  return 0;
}
__________________
Valmont is offline   Reply With Quote