Define the operator [] , which will return the string - as a pointer, vector or something else, for which the operator [] defined, which will return a reference to a specific element ...
The simplest example is:
class Matrix { public: Matrix(int R, int C):R(R),C(C) { d = new int*[R]; for(int i = 0; i < R; ++i) d[i] = new int[C]; } ~Matrix() { for(int i = 0; i < R; ++i) delete[] d[i]; delete[] d; } int* operator[](int idx) { return d[idx]; } const int* operator[](int idx) const { return d[idx]; } private: int ** d; int R, C; }; int main() { Matrix M(3,3); for(int i = 0; i < 3; ++i) for(int j = 0; j < 3; ++j) M[i][j] = 10*i + j; for(int i = 0; i < 3; ++i) { for(int j = 0; j < 3; ++j) { cout << setw(2) << M[i][j] << " "; } cout << endl; } }
Naturally, no errors are processed by me.