Dear Rooters
Sorry for asking a general C++ question but I have problems
to pass a two-dimensional array to a function.
In MyMethod() I have created a two-dimensional array:
void MyMethod(Int_t ncols, Int_t nrows)
{
Double_t **table = 0;
table = new Double_t*[ncols];
for (Int_t i=0; i<ncols; i++) {
table[i] = new Double_t[nrows];
}
// fill table with data before calling:
DrawTable(nrows, ncols, table, opt); //<==compile error
}
The function DrawTable() looks as follwos:
void DrawTable(Int_t n, Int_t m, Double_t &table, Option_t *opt)
// write: Double_t &table or: Double_t **table ??)
{
Double_t *index = 0;
index = new Double_t[n];
for (Int_t i=0; i<n; i++) index[i] = i;
TGraph *graph = 0;
for (Int_t i=0; i<m; i++) {
graph = new TGraph(n, index, table[i], opt); //<==compile error
graph->Draw(opt);
SafeDelete(graph);
}
delete [] index;
}
How do I have to pass the variable table to get the code
to compile correctly?
Please note that I know that I could use TMatrix (or TTable)
to create my table, but I would like to know how to write the
code correctly in this way.
Thank you in advance for your help.
Best regards
Christian
_._._._._._._._._._._._._._._._
C.h.i.s.t.i.a.n S.t.r.a.t.o.w.a
V.i.e.n.n.a A.u.s.t.r.i.a
_._._._._._._._._._._._._._._._
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:21 MET