ui@ui:~$ root -l
root [0] TObjArray *a = new TObjArray()
root [1] a->operator[]
tab completion not implemented for this context
root [1] a->operator[]
Error: Symbol a is not defined in current scope (tmpfile):1:
Error: Failed to evaluate a->operator[]
*** Interpreter error recovered ***
I think a clarification is needed here.
The operator[] makes the TObjArray behave like an array (or a vector) for what concerns the access of its elements: this is what the documentation is saying. The second part of your example refers to the initialisation. This latter cannot be expressed with curly braces.
I think a clarification is needed here.
The operator[] makes the TObjArray behave like an array (or a vector) for what concerns the access of its elements: this is what the documentation is saying. The second part of your example refers to the initialisation. This latter cannot be expressed with curly braces.
Cheers,
Danilo[/quote]
Hi Danilo,
Sorry I don’t get your point. As a array, I think there are some behaviors like:
root [0] int a[5] = {1,2,3,4,5} //the initialization
root [1] a //call a
(int*)0x142e800
root [2] a[0] //visit the element by ordinal number
(int)1
for vector, some behaviors like pop() push_back() provided. I think behaviors is something like method or attribute.
But for TObjecArray:
root [0] TObjArray a1[5] = {1,2,3,4,5}
root [1] a1
(class TObjArray*)0x1644ec0
root [2] a1[0]
(class TObjArray)23350976
root [3] a1[2] //when I want to visit the element, it dose not return the element ?
(class TObjArray)23351104
root [4] a1[1:3]
Warning: Illegal numerical expression 3] (tmpfile):1:
(const int)3
root [5] a1.operater[]
Error: Symbol a1 is not defined in current scope (tmpfile):1:
Error: Failed to evaluate a1.operater[]
*** Interpreter error recovered ***
root [6] a1.operater[0]
Error: Symbol a1 is not defined in current scope (tmpfile):1:
Error: Failed to evaluate a1.operater[0]
*** Interpreter error recovered ***
After the initialization , I do not know how to visit the element ,let alone how to control it like a ‘real’ array ( or vector ) with pop() or other methods.
Hi ,
Thanks a lot !
I didn’t realize it is a pointer and I find it is strange that I can not use operator * to get the value of the pointer. Again, thanks a lot for your patient.