Re: [ROOT] room to read a ROOT Tree

From: Rene Brun (Rene.Brun@cern.ch)
Date: Wed Mar 21 2001 - 11:10:04 MET


Hi Francois-Xavier,

As you have found, both solutions work:
  Event *event = 0;
or
  Event *event = new Event();

The first form is in general recommended (pointer must always be set to 0).
You can use the second form in case you have to do something special in the
constructor or you want to call the non-default constructor.

Rene Brun


GENTIT Francois-Xavier DAPNIA wrote:
> 
>   Dear Rooters,
>   I got confused reading the ROOT documentation on the subject "How to read
> a Tree".
> 
>    -  If you look at the example given in "ROOT Overview", page 49, chapter
> "How to read a Tree", the space for the pointer "event" is not allocated, we
> have simply the line :
>     Event *event = 0;    no "new" anywhere.
> 
>    -  If you look at the example given in "ROOT Tutorials", page 45,
> "Reading all events of a ROOT Tree", (or on the web at
> http://root.cern.ch/root/html/examples/eventa.cxx.html ) the pointer "event"
> is allocated, you have the line :
>    Event *event = new Event();
> 
>   I have made tests, and to my surprise, both solution are working ! How is
> it possible ? What is the recommanded way of doing ?
>   Thanks a lot in advance.
> 
>           F.X. Gentit
>           DAPNIA/SPP CEN Saclay
>           tel : 01 69 08 30 38     fax : 01 69 08 64 28
>           web : http://home.cern.ch/~gentit/



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:40 MET