TTree with c-struct-like class : vtable error

Hi,

So I am trying to make a TTree and set its leaves with a c-struct-like class. So just before my main, I add the c-struct-like class defining my variables. When I make this, I get an error that says “undefined reference to `vtable for NewClassVar’”. But it turns out, if I remove the line that says " ClassDef (NewClassVar,0);" the make works. What am I missing here?

I looked in root.cern.ch/drupal/faq#n676 but I am not sure how I can implement it since I am not ACLiC-ing, and instead am make-ing.

This is sort of the sample code I am using:

#include <TTree.h>

class NewClassVar : public TObject
{
public:

int var1; //event index
double var2; //xposition of events

NewClassVar():
var1(0),
var2(0.){}

ClassDef (NewClassVar,0);
};

class A: public B::CFunction {
this here calculates values and fills the tree.
}

Thanks!

  • Sujeewa

Ok, so I had forgotten to put the appropriate LinkDef.h file with the pragma link line. #-o It works now (well up to the point that I can compile it and run it, but I can not seem to fill the tree: see next post - Correct way to fill TTree using a variable class)!