Re: [ROOT] Ctor called on file load ??

From: Rene Brun (Rene.Brun@cern.ch)
Date: Tue Dec 04 2001 - 15:13:38 MET


Joe,

static members are not made persistent. 
When Root reads back an object from a file, 
 - it creates an "empty" object of the class by calling the default constructor
   with no parameters.
 - with this empty object obj, it calls obj->Streamer(buffer) to fill the data
   members by reading the data from the buffer.

In your case, you simply have to put the static counter in your constructor(s)
and increment it by one.

Rene Brun

joe robe wrote:
> 
> Hi Rooters,
> 
> I guess the Ctor is NOT called if one loads an object
> form disk and only the saved data members are loaded.
> 
> I have a class with an static class member which
> counts ho many instances of the class have been
> created.
> 
> Of course I can tell the dict file NOT to write this
> member to disk, but how do I get my class count then ?
> Is there any other wat than MANUALLY increase it after
> each object load ?
> 
> Joe
> 
> __________________________________________________
> Do You Yahoo!?
> Buy the perfect holiday gifts at Yahoo! Shopping.
> http://shopping.yahoo.com



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