I'm relatively new to C++, thus the question. I'm trying to overload () operator for read and write operations in an array. This is a row-major array which maps a two -dimensional array to a one dimension.
This is the overload that I've written for read operations
//overloading read operator
const double& operator()const(int n, int m){
return arr_[n*column+m];
}
Now I need to write a write overload that inserts a double value in the position returned by the read overload.
//overloading write operator
double& operator()(double d){
}
How exactly can I do that. Any help appreciated.
constsand you can saydata(x,y) = 0;.constin the wrong place in your existing code, member modifiers (cv-qualifier-seq) go after the argument list.