C++ [] operator overload - TechRepublic
General discussion
June 23, 2002 at 12:47 PM
solrak29

C++ [] operator overload

by solrak29 . Updated 21 years, 6 months ago

I want to do something very simple. I want an object where I define two subscript operator (i.e. [] ) functions. I want one that will return to the user a value that is modifiable and one that will return to the user a value that can not be modified so that if I do this:

Object a = b[2];

The “read only” function will get called.
And if I do this…

b[2] = new Object.

The “write” function will get called.

This discussion is locked

All Comments