View Single Post
Old 11-02-2004, 06:57 PM   #4 (permalink)
deekaybee
Upright
 
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!
deekaybee is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76