Is it possible to implement a function to access a private data vector foo in a class via class[i][j]? This should call the inner function of the vector foo[i][j].
Is it possible to implement a function to access a private data vector foo
Share
A simple solution is to implement
operator[]so it “peels off” only the first dimension:You need the two overloads because of const correctness. (If you only want to grant read access, not write access, you don’t need the non-const version, of course.)