Hy Yves, Assume your singleton AliPHOSGeometry geom with its protected constructor, you can write it to a file with geom.Write(name) or geom.Write(); // if the class derives from TNamed Now, to read it, I assume you already have somewhere an instance of this object called geom. You can read in this object the content of the previously saved object with geom.Read(name) Invoking TObject::Read uses the existing object and there is no need for the system to create an object via the default constructor. The same is true if your special object is a data member of another object: Example class GeomAll : public TObject { protected; AliPHOSGeometry fPHOSGeom; You can read an object of class GeomAll with a statement like GeomAll *allgeom = (AllGeom*)file.Get("somename"); You cannot have a pointer to an object with a protected constructor; AliPHOSGeometry *fPHOSGeom; will not work as it requires a call to the default constructor before invoking the corresponding Streamer function. Rene Brun Yves SCHUTZ wrote: > > Hi, > > I would like to raise my question again. I have a > singleton called AliPHOSGeometry (the default > constructor is protected) which I made persistent > (derive it from TObject). So far I made an object > of this singleton a data member of an other object > which I write to disk. When trying to access the > object of the singleton I get the following error > message: > > Error in <TClass::New>: no default ctor for class > AliPHOSGeometry > Error in <TBuffer::ReadObject>: could not create > object of class AliPHOSGeometry > > How can this problem be solved? > > Thanks ... Yves > -- > > __________________________________________________________________ > |Yves SCHUTZ (IN2P3 - CNRS) collaboration > TAPS/WA98/ALICE | > |SUBATECH > | > |Ecole des Mines de Nantes Telephone: (+33/0) 2 51 > 85 84 71 | > |4, rue Alfred Kastler Fax : (+33/0) 2 51 > 85 84 79 | > |F-44070 Nantes cedex 03 e-mail : > yves.schutz@subatech.in2p3.fr| > |__________________________________________________________________|
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:43 MET