In various examples i saw that you can make different operators in a class for reading and for writing to a class array element. But when i try this example on Mingw and Borland it always calls the writing operator.
class Point3 { float coord[3]; public: float operator [] (int index) const; // For reading float & operator [] (int index); // For writing }; float Point3::operator [] (int index) const { printf("reading... \n") ; return 123.0*coord[index]; } float & Point3::operator [] (int index) { printf("writing... \n") ; return coord[index]; } int main(int argc, char* argv[]) { Point3 xyz ; xyz[0] = 1.0 ; printf("%3.2f",xyz[0]) ; return 0 ; } output: writing... writing... 1.00