#ifndef MATRIX_PROXY_H #define MATRIX_PROXY_H #include "range.h" #include "matrix_expression.h" /***************************************************** * matrix_proxy class ****************************************************/ class matrix_proxy : public matrix_expression { private: matrix_expression& M; // reference to the underlying source matrix const range rows; // copy of range describe extent of rows const range cols; // copy of range describing extent of columns public: // use inherited assignment operator (rather than default) using matrix_expression::operator=; matrix_proxy& operator=(const matrix_proxy& other); // constructor matrix_proxy(matrix_expression& src, const range& r, const range& c); int numRows() const; int numColumns() const; // we need following declaration to properly inherit the version of // operator() for ranges. Then we can define our additional ones. using matrix_expression::operator(); // read-only version of indexing operator double operator()(int r, int c) const; // write-access version of indexing operator double& operator()(int r, int c); }; #endif