Hi Jianglai,
You have two options
-the simple one: no need to derive from TGraph. Simply call
TGraph(n,&xy[0], &xy[1]);
Unless your storage in xy is the wrong way (Fortran-wise)
-Making TMyGraph with a constructor like
TMyGraph::TMyGraph(Int_t n,Float**y)
:TGraph(n) {
for (Int_t i=0;i<n) SetPoint(i,xy[0][i],xy[1][i]);
}
Rene Brun
Jianglai Liu wrote:
>
> Dear ROOTers,
>
> This is pretty much a C++ question. I would appreciate any help.
>
> I like to create a derived class from TGraph, which takes a more
> complicated class object in the constructor, processes it, and then
> invokes TGraph(n,x,y) c-tor.
>
> To demonstrate, suppose we have a 2D array xy[2][n]. In pseudo-code, I
> like the class c-tor to do something like:
>
> TMyGraph(Float** xy, n){
> -- split xy[2][n] into x[n] and y[n];
> -- invoke TGraph(n,x,y) c-tor
> }
>
> So I don't want to invoke TGraph c-tor right at the beginning of the
> implementation. I know I can achieve the same thing by having a TGraph
> object member in this new class, instead of deriving it from TGraph. But I
> feel it is much less transparent for futher handling of the class. Eg.
> later I want to add bunches of these objects into a TMultiGraph ...
>
> Is there a way to do such things? Thanks in advance!
>
> Jianglai
>
>
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:16 MET