I want to represent my object like an array. I mean that the programmer can write in his code
myobject[3]=2
In the back (in myobject code) there isn’t an array at all, it’s only representation.
So I need to overload [] and = simultaneously.
How can this be done?
thank you,
and sorry about my poor English.
operator[]should return a reference to object you are trying to modify. It may be some kind of metaobject, that overloadsoperator=to do whatever you wish with your main object.Edit: As the OP clarified the problem, there is a way to do this. Look here: