I know that for a simple 2d matrix like:
class Matrix{
vector<vector<int>> data;
};
In order to support operation like Matrix[][], you just need to overload operator[] which returns the corresponding row vector like:
vector<int>& operator[](int row){return data[row]};
My question is how to implement the subscript operator if I need to perform some transformation on the col. Say for i th row, the size of that row is 10.
I want to return the actual data when j is less than 5 but some other value say i+j when j is greater than 5.
Is there a way to achieve this? Thanks!