Re: [ROOT] TGraph crash when using dynamic array

From: Jiri Masik (masik@pc203b.fzu.cz)
Date: Fri Oct 12 2001 - 20:43:30 MEST


joe robe <joer00@yahoo.com> writes:

> Hi rooters,
> 
> this might be more a C++ beginners problem, but i cant
> figure out why this crahses
> 
> void DrawGraph(RowNr)
> {
> Double_t* x=new Double_t(NrColumns);
[...]
> delete [] x;

Hi Joe,

it should read Double_t* x=new Double_t[NrColumns]; to create an
array of Double_t's. You're allocating just a single Double_t and
assigning NrColumns to it.

Jiri



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