Hi Jens, I have made some editing in your header file. In particular note the change from virtual void ~TFileData() {} to virtual ~TFileData() {} #include "TObjArray.h" #include "TArrayF.h" #include "TArrayI.h" class TFileData : public TObject { private: Bool_t fAvsFound, fSigsFound; const Int_t fMaxPads; Int_t fAnode, fField; Char_t fFileName[50]; TArrayI fNoClusters; TArrayF fChargeAvs, fChargeSigs, fPeakAvs, fPeakSigs; TObjArray fClusters; virtual void SetMaxPads(const Int_t pads) {} virtual void Init(const Int_t n); public: TFileData(); TFileData(const Int_t pads, const Char_t* name, const Int_t anode = 0, const Int_t field = 0); virtual ~TFileData() {} }; Rene Brun Jens Ivar Jordre wrote: > > Hello rooters of the world. > > A problem with deletion has arisen when trying to delete instances of a > class I made. > > --------------- > > My header file: > > class TFileData : public TObject { > private: > Bool_t fAvsFound, fSigsFound; > const Int_t fMaxPads; > Int_t fAnode, fField; > Char_t fFileName[50]; > TArrayI fNoClusters; > TArrayF fChargeAvs, fChargeSigs, fPeakAvs, fPeakSigs; > TObjArray fClusters; > virtual void SetMaxPads(const Int_t pads) {} > virtual void Init(const Int_t n); > > public: > TFileData(); > TFileData(const Int_t pads, const Char_t* name, const Int_t anode = 0, const Int_t field = 0); > virtual void ~TFileData() {} > .... > }; > > Member functions: > > #include "TFileData.h" > > TFileData::TFileData() : fMaxPads(40) { > strcpy(fFileName,"NN"); > fAnode = 0; > fField = 0; > Init(fMaxPads); > } > > TFileData::TFileData(const Int_t pads, const Char_t* name, const Int_t anode, const Int_t field) > : fMaxPads(pads) { > > strcpy(fFileName,name); > fAnode = anode; > fField = field; > Init(fMaxPads); > } > > virtual void TFileData::Init(const Int_t n) { > // > //Initialize members. > // > fNoClusters.Set(n+1); > fChargeAvs.Set(n+1); > fChargeSigs.Set(n+1); > fPeakAvs.Set(n+1); > fPeakSigs.Set(n+1); > fAvsFound = kFALSE; > fSigsFound = kFALSE; > } > > .... > > ---------------- > > I don not precomile it, only load it as is with > gROOT.LoadMacro("TFileData.C"); > > Making an instance is no problem: > root [0] fd = new TFileData(30,"file1",1200,300) > (class TFileData*)0x8888b48 > > My problem is that I don't manage to delete it: > root [1] delete fd > > *** Break *** segmentation violation > Root > Function ~TFileData() busy flag cleared > > I'm using v. 2.23/12 on RH6.1 > > I also enclose a very similar class which I use in the same > way. Instances of this one are easily deleted. > > ----------- > Header: > > class TVoltData : public TObject { > private: > Bool_t fAvsFound, fSigsFound; > const Int_t fMaxPads; > Int_t fVolt; > TArrayI fNoClusters; > TArrayF fChargeAvs, fChargeSigs, fPeakAvs, fPeakSigs; > TObjArray fClusters; > virtual void SetMaxPads(const Int_t pads) {} > virtual void Init(const Int_t n); > > public: > TVoltData(); > TVoltData(const Int_t pads, const Int_t volt); > virtual void ~TVoltData() {} > .... > }; > > Member functions: > > #include "TVoltData.h" > > TVoltData::TVoltData() : fMaxPads(40), fVolt(1000) { > Init(fMaxPads); > } > > TVoltData::TVoltData(const Int_t pads, const Int_t volt) : fMaxPads(pads), fVolt(volt) { > Init(fMaxPads); > } > > virtual void TVoltData::Init(const Int_t n) { > // > //Initialize members. > // > fNoClusters.Set(n+1); > fChargeAvs.Set(n+1); > fChargeSigs.Set(n+1); > fPeakAvs.Set(n+1); > fPeakSigs.Set(n+1); > fAvsFound = kFALSE; > fSigsFound = kFALSE; > } > > .... > > -------------- > > -------------------------------------------------------------- > Jens Ivar Jřrdre, masterstud. in Experimental Nuclear Physics > Addr.: Dep. of Phys., UiB, Allégt. 55, N-5007 BERGEN, NORWAY > E-mail: JensIvar.Jordre@fi.uib.no, Phone office: (+47)55582734 > Web: http://www.fi.uib.no/~jens > > "Time's fun when you're having flies." > -- Kermit the Frog
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:22 MET