Trouble in accessing items in RArray???
| Wed, 2007-11-07 03:48 | |
|
i have a piece of code below: CMyClass.h typedef RArray< TAny* > TListenerList; typdedef RArray< TListenerList > TListenerHandler; TListenerHandler iHandlers; CMyClass.cpp when i set aType = EListener1 or aType = EListener2, it raises USER 130 Can someone explain why? ht_it |
|






Forum posts: 587
Well this happens because you have less elements in your array than the parameter value is. E.g. if aType equals 1 (EListener2) and your array has 0 or one elements, the array is out of bounds (you try to access an element which cannot be in the array).
Forum posts: 3
Andreas,thank you for replying.
now, i understand,but i don't know how to initialize iHandlers(e.g 3 elements),so that i can access the array.
Do you have any suggestion?
ht_it
Regard,
Forum posts: 587
Well, it is a dynamic array. You need to add elements to it. Now it is apparently just empty. See the array's Append/AppendL methods. And please read introductory topics on these issues. If you do not understand what is a dynamic array, I guess you have a hard path ahead of you. Stop coding for a while and read more.