Strange Behaviour with TClonesArray?

I encountered a strange behaviour with a TClonesArray, which may eventually be caused by a selection of the wrong operator of the parent class TObjArray?
virtual TObject*& operator[](Int_t i)
virtual TObject* operator[](Int_t i) const

When I create an TClonesArray GetEntries shows that it is empty, but as soon as I access an Array Entry with the operator[](Int_t i) member function a random Entry seems to be created.

my root version is 4.00/08

example Code:

root [4] TClonesArray test2(“TObject”,128)
root [6] test2->GetEntries()
(const Int_t)0
root [7] test2[6]
(class TObject*)0x8e39b30
root [8] test2->GetEntries()
(const Int_t)1

A TObjArray doesn’t show this behaviour.

cheers
Dirk

[quote]When I create an TClonesArray GetEntries shows that it is empty, but as soon as I access an Array Entry with the operator[](Int_t i) member function a random Entry seems to be created.[/quote]By design, you can never add existing object into a TCLonesArray. Instead, the TClonesArray is responsible for the memory management of its content. One of the direct effect is that ‘accessing an element’ induces its creation. The created object is not random by is an object of the given class (TObject in your example) created using the default constructor.

Cheers,
Philippe.