Michael DeWulf wrote:

> I am trying to make a 2D matrix class. The data in the matrix will be of

> type int and so the underlying data structure will be a 2D array (int **

> matrix). To make the data easy to modify, I would like to be able to

> modify this private array in the class with the operator [][]. I know

> that the operator[] can be overloaded. However, is there away to overload

> [][]?
No, but [,] is "overloadable":

By Jack Saalweachter

struct MagicInt {

// operator overloads, constructors, etc, to make this class behave

// as an integer.

};

std:

air<MagicInt, MagicInt> operator , (const MagicInt &a, const

MagicInt& b) { return std::make_pair(a, b); }

class Array2d {

public:

value& operator[](const std:

air<MagicInt, MagicInt> &a) {

// use a.first and a.second to find the value...

}

};

int main() {

Array2d M(X, Y);

for (MagicInt a = 0; a < X; ++a)

for (MagicInt b = 0; b < Y; ++b)

M[a, b] = i + j;

}

Of course, overloading (,) works better and is a lot easier.