// -*- coding: utf-8 -*- // Time-stamp: // Implementation of 2d m×n arrays with an array for each line #ifndef ARRAY2DI_H #define ARRAY2DI_H class Array2di { public: // Constructors // Default constructor with no allocation Array2di() : nlin(0), ncol(0), p(nullptr) {}; // Constructor from dimensions Array2di(int m, int n); // Constructeur de copie Array2di(const Array2di& a); // Assignment operator Array2di& operator=(const Array2di& a); // Access operator to a non-constant array double& operator()(int i, int j); // Access operator to a constant array const double& operator()(int i, int j) const; // Destructor ~Array2di() { free(); } private: // Alloc the array // + nlin and ncol must be valid void alloc(); // Free the array void free(); // Copy from another array void copy(double** t); int nlin; // Number of lines int ncol; // Number of columns // Array of pointers // Each p[i] contains a pointer to the array for line i. double** p; }; #endif