Hello everybody,
I'm new in c++ and im trying to overload the [] operator for a two dimension array.
I found out that I cant overload straight for the 2-D array because the first [] must return an pointer type and the second one an integer type.
I can overload the () operator and use a syntax like follow:
1 2 3 4 5 6 7 8
class patoma{
int **pinakas;
public:
int &operator()(int x, int y);
};
int &patoma::operator()(int x, int y){
return pinakas[x][y];
}
But I was wondering why is the same thing impossible with the []?
And what i mean is to use [x, y].
Isn't it the same thing?
Is there any way to make the [] operator to take two arguments?