Re: Question w.r.t. TObjArray and TClonesArray

From: Christoph Borgmeier (borg@ifh.de)
Date: Thu Apr 16 1998 - 18:54:51 MEST


Dr. Nick van Eijndhoven wrote: 
[...]
> - Once I have several Tracks created I want to group
>   them together into a vertex.
>   For this I have a class Vertex which has in its
>   private area an array to store the pointers to
>   the related Track objects.
> 
>   i.e.    Track** save;
> 
>   and in the Vertex constructor I do :
> 
>           save=new Track*[n];
[...]
> Then I got the idea of using TObjArray or TClonesArray
> for this, but as far as I can see from the docs,
> these facilities can only store objects and not only
> pointers to objects.
[...]

Hello Nick,

as far as I understand the docs, you can do

TObjArray* save;

and

Track* x = ...
save->Add( x );

This works fine for me (reading and writing ROOT files).
In the roottalk digest you find some more discussion on that
(30 Mar-2 Apr). If you run into trouble with memory leaks,
I could post my the latest version of my garbage collector.

Hope that helps
Christoph



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:32 MET