Hi,
I want to create an array of TGraphErrors.
Is it possible and how?
int n = 50;
TMultiGraph *mg = new TMultiGraph();
TGraphErrors *gr[n];
for( n = 0; n < i; n++ )
{
*gr[n] = new TGraphErrors( 1, &redshift[n], &gamma[n], &eredshift[n], &egamma[n] );
gr[n]->SetMarkerColor(n+2);
gr[n]->SetLineColor(n+2);
gr[n]->SetMarkerStyle(20);
mg->Add( gr[n] );
}
This code gives me errors:
plot_sources.cpp:58:14: error: no viable overloaded ‘=’
*gr[n] = new TGraphErrors( 1, &redshift[n], &gamma[n], &eredshift[n], &egamma[n] );
~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/root/root_v5.34/include/TGraphErrors.h:55:18: note: candidate function not viable: no
known conversion from ‘TGraphErrors *’ to ‘const TGraphErrors’ for 1st argument; dereference
the argument with *
TGraphErrors& operator=(const TGraphErrors &gr);
^
1 error generated.