michael_hartman_cz

array2

Apr 22nd, 2013
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. template <class X>
  2. class array2
  3. {
  4.     public:
  5.       array2(const int row_count = 0, const int col_count = 0) : rows (row_count), cols(col_count)
  6.       {
  7.         m_arr = new X*[rows];
  8.         for (int r = 0; r < rows; ++ r )
  9.             m_arr[r] = new X[cols];      
  10.       }
  11.       X & operator() ( const int r, const int c )
  12.       {
  13.           return m_arr[r-1][c-1];        
  14.       }
  15.      
  16.     private:    
  17.       int   rows, cols;
  18.       X **  m_arr;
  19. };
Advertisement
Add Comment
Please, Sign In to add comment