Hello,
could someone please help me as I'm utterly confused.
I'd like to create a new object to be used in TTree -s. I did create the following:
MyEvent.h
class MyEvent : public TObject {
public:
MyEvent();
~MyEvent() {};
void setNr(Int_t nr);
Int_t getNr();
private:
Int_t nr;
ClassDef(MyEvent,1)
};
MyEvent.cpp
void MyEvent::setNr(Int_t nr_new) {
nr = nr_new;
}
Int_t MyEvent::getNr() {
return nr;
}
MyEvent::MyEvent() {
nr=0;
}
ClassImp(MyEvent);
test.cpp
int main(int argc, char **argv) {
MyEvent * ev = new MyEvent(); ev->setNr(1); cout << "Event nr: " << ev->getNr() << endl; return 0;
compiling it results in this:
[oberon] /home/mario/pythia/test > g++ -o libparticles.so -shared -
rdynamic -O -Wall -fPIC MyEvent.cpp `root-config --cflags --libs --
glibs`
[oberon] /home/mario/pythia/test > g++ -o test test.cpp `root-config
--cflags --libs --glibs` -L$PWD -lparticles/home/mario/pythia/test/
libparticles.so: undefined reference to `vtable for MyEvent'
/home/mario/pythia/test/libparticles.so: undefined reference to
`ROOT::GenerateInitInstance(MyEvent const*)'
collect2: ld returned 1 exit status
what am I doing wrong? I really need just a basic class with some objects to use in trees. The trouble is there is no simple example I could reference ...
"Physics is like sex, sure it may give some practical results, but that's not why we do it"
This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:31:59 MET