Re: About matrix subscripting index
On 29 mar, 08:57, "Jim Langston" <tazmas...@rocketmail.com> wrote:
d major wrote:
I want to implement a Matrix class for numeric computing,
just like this:
class myMatrix{
public:
myMatrix(int m,int n);
...
private:
size_t row,col;
double **mat;
};
So, if I instantiate a matrix
myMatrix T;
how can I override this operator '[ ][ ]' s.t. T[i][j] can be used?
By the way, could you share your instance of matrix for me?
[][] can't be overridden, but what you can do is override []
and have it return a proxy unit where [] you override []
again.
This is one way to do it, but it is somewhat frowned upon and
overriding () taking two parameters is suggested.
Some people frown upon it, and others find it preferable. As
Uwe-Kai said, there isn't really a consensus about this.
Overriding () with two parameters doesn't require a proxy
object.
Which may make it slightly easier to implement. The choice,
however, should be based on your team's opinion as to which is
the better philosophy for the interface.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34