C++ overload operator [ ][ ]

后端 未结 5 1886
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-28 12:35

I have class CMatrix, where is \"double pointer\" to array of values.

class CMatrix {
public:
    int rows, cols;
    int **arr;
};

I simpl

5条回答
  •  情歌与酒
    2020-11-28 12:39

    You could operator[] and make it return a pointer to the respective row or column of the matrix. Because pointers support subscripting by [ ], access by the 'double-square' notation [][] is possible then.

提交回复
热议问题