Initializing an array of TList

How can I initialize 360 of TList ? And clear memory after

Hi,

perhaps the problem you are solving may have better solutions but this

auto l = new TList[360]
delete[] l;

is what you are looking for.
D

Hello, dplparo
thank you very much! Can you help me one more time?
How do I add elements to TList in loop?
I know that Add, but how is it right to write and display?

Hi,

that is an array of TLists. You can access the elements with the operator []. Once you have in hands a pointer to a TList, you can rely on the online documentation to see how to add elements to it: https://root.cern.ch/doc/master/classTList.html

D

Thank you, dpiparo
So, I guess function TList::AddLast(obj);
But I misunderstanding, is it needed to include TList.h and TList.cxx library?
And how do I add in l[i] ?

Hi,

you access an array with the [] operator. So you do l[3].AddLast(myObj). You do not include cxx files. You include TList.h only if you compile, you don’t if this is a macro.

Cheers,
D

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.