You can only overload [] by member functions of a class. Same goes for = () ->
Not sure if this is what you mean WRT a class behaving like an array with different semantics...Use the STL containers.
Use iterators to navigate over STL containers like the vector, and for element access use at(). You can try/catch an out of range error on the at() command as it does a range check. If you want you can still use the operator[], but you have to make sure you perform the range check. Iterators have the begin()/end() functions that should be used.
__________________
It's not that I don't care, it's just that I don't care enough!
|