Re: Streamers and pointers to data members

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Wed, 26 Nov 2008 15:33:48 +0100


Yes, you MUST set to 0 all your pointers in the default constructor. By the way see interesting option -Weffc++ (from Scott Myers book), this will tell you what you are doing wrong in your constructors ::)

Rene brun

Philip Rodrigues wrote:
> Hi roottalk,
> I have a class with a data member which is a pointer to a TH2F. I can
> successfully stream it to disk, but when I read it back, I get a
> crash. The crash goes away if I set the TH2F pointer to zero in the
> default constructor. (The attached file contains a minimal example -
> run the "testrun.C" macro).
>
> So my question is, do I always need to set pointers to zero in default
> constructors, or have I run into a bug? I couldn't see any mention of
> this in the documentation.
>
> Thanks,
> Philip
Received on Wed Nov 26 2008 - 15:28:41 CET

This archive was generated by hypermail 2.2.0 : Wed Nov 26 2008 - 17:50:02 CET