Re: writing/reading objects to/form a file

From: Stan Seibert <volsung_at_physics.utexas.edu>
Date: Sun, 20 Nov 2005 17:20:57 -0600

On Nov 20, 2005, at 11:12 AM, Axel Naumann wrote:

>> class AliTOFCalib: public TObject
>> {
>> public:
>> AliTOFCalib() {fPads= new AliTOFCalParam[npad];}

<snip, snip>
>
>> virtual ~AliTOFCalib(){delete[] fPads;}
>>
>
> This is the wrong delete operator. You only have one element in fPads
> (i.e. it's not a C array, as in Int_t *aCArray; aCArray=new Int_t[10],
> where you have aCArray pointing to 10 Int_ts, and where you need to
> use
> delete[], the array deleting operator). See e.g.
> http://www.informit.com/guides/content.asp?g=cplusplus&seqNum=31

Reread the line where new is used: There are brackets after new AliTOFCalParam, not parens, so delete[] is the appropriate operator to use when freeing the memory.

---
Stan Seibert
Received on Mon Nov 21 2005 - 00:21:19 MET

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:13 MET