[ROOT] TGraph crash when using dynamic array

From: joe robe (joer00@yahoo.com)
Date: Fri Oct 12 2001 - 19:01:41 MEST


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);
Double_t* y=new Double_t(NrColumns);
for(Int_t i=0;i<NrColumns;i++)
{
	x[i]=i;
	y[i]=GetRow(RowNr)->At(i);
}
TGraph* Graph=new TGraph(NrColumns,x,y);
delete [] x; // CRASH HERRE !! if i dont delete crash
in the next method call !
delete [] y;
}

It works FINE when I use x/y as stack objects but i do
not know in advance the nr of datapoints !!!

Joe



__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com



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