[ROOT] Object Inheritance.

From: Patrick Murray (pjmurray@ucdavis.edu)
Date: Wed Mar 20 2002 - 23:46:59 MET


So all objects most inherit from TObject. I can not get my new class to
work right. Here are some of my errors. When I use (myClass).Inspect none
of my variable show up. But when I make a tree, they are there but when I
try to fill them I can not. As I told you, I am trying to get to the data
in a way which is more like C than C++ because my class is derived from a
C srtuct. I do not think this is the problem

I would like to ask about this:

FILE:test.h LINE:54
!!!There are some limitations regarding compiled/interpreted class
inheritance

and why you choice to make your Event class in a lib rather than just
leaving it an interpreted class. Could this relate to my problem?

Thank you,

Pat

I also include some code but most likely not enough to be of use.

root [0] .L testt.cpp+
Info in <ACLiC>: creating shared library
/home/pmurray/solar2/root/./testt_cpp.so
In file included from /home/pmurray/solar2/root/fileroNgVA.h:29,
                 from /home/pmurray/solar2/root/./fileroNgVA.cpp:5:
/home/pmurray/solar2/root/./testt.cpp: In function `void TEST ()':
/home/pmurray/solar2/root/./testt.cpp:102: type `Run' is not a base type
for type `TObject'
/home/pmurray/solar2/root/./testt.cpp:103: type `Run' is not a base type
for type `TObject'
/home/pmurray/solar2/root/./testt.cpp:106: cannot convert
`*((run->Run::fevents +
(+(run->Run::numEvents * 48))) - 48)' from type `TClonesArray' to type
`Event *'
/home/pmurray/solar2/root/./testt.cpp:109: base operand of `->' has
non-pointer type `TClonesArray'
/home/pmurray/solar2/root/./testt.cpp:115: warning: unused variable `char
word[10]'
/home/pmurray/solar2/root/./testt.cpp:116: warning: unused variable `char
word2[10]'
g++: /home/pmurray/solar2/root/./fileroNgVA.o: No such file or directory
root [1] .L testt.cpp
Warning: Interpreted class Event derived from precompiled class TObject
FILE:test.h LINE:54
!!!There are some limitations regarding compiled/interpreted class
inheritance
Warning: Interpreted class Run derived from precompiled class TObject
FILE:test.h LINE:107
!!!There are some limitations regarding compiled/interpreted class
inheritance
root [2]

some code

Run *run= new Run();

Event *pointerToEvent=new Event;
//pointerToEvent=&event;

void TEST(void){
  Int_t i=0;

  Event *even= new Event;
  Event *eventt= new Event;
  eventt->Inspect();
  TClonesArray a("Run",1000);
  even->evnum=1000;
  run->Inspect();
  cout<<even->evnum<<endl;
  for (i=0; i<1000;i++)
    {
      new(a[i]) Run();
      a[i]->Run::rnum=i;
      cout<<a[i]->Run::rnum<<endl;
      run->AddEvent();

      *even=(Event*)run->fevents[run->numEvents-1];
      even->evnum=i;
      cout<<even->evnum<<endl;
      cout<<run->fevents[run->numEvents-1]->Event::evnum<<endl;
    }

  cout<<run->numEvents<<endl;
  cout<<pointerToEvent->evnum<<endl;

  Char_t word[10]="hi";
  Char_t word2[10]="bye";
  cout<<"hi?"<<endl;
  even->evnum=130;
  cout<<even->evnum<<endl;
  even->print();
}



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:46 MET