Hi,
Please look at the code below
//myclass.h
#include "TNamed.h"
class myclass: public TNamed
{
public:
int a;
myclass();
myclass(const char* name);
ClassDef(myclass,1);
};
//myclass.cc
ClassImp(myclass);
myclass::myclass() {}
myclass::myclass(const char* name){SetName(name);}
//testclass.cc
#include "myclass.cc"
#include "TFile.h"
int main()
{
static myclass* cuts=new myclass("somename");
cuts->a=4;
TFile f("test.root","recreate");
cuts->Write();
}
And shell commands:
$> rootcint -f dict.cc -c myclass.h
$> g++ -Wall `root-config --libs --cflags` -o testclass testclass.cc dict.cc
$> ./testclass
$> root
root [0] #include "myclass.cc"
root [1] TFile f("test.root");
root [2] gDirectory->ls();
TFile** test.root
TFile* test.root
KEY: myclass somename;1
root [3] myclass *m = (myclass*)gROOT->FindObject("somename");
Error in <TBuffer::CheckByteCount>: object of class TNamed read too few bytes: 18 instead of 32
What am i missing?