When my very simple class is attempted to be read, I get the above message:
Fatal in TKey::ReadObj: Incorrect detection of the inheritance from TObject for class SctArchiving::RootInteger
Can you help?
The class appears in the TClassList
class version bits initialized
SctArchiving::RootInteger 1 0 Yes
main looks like:
#include “…/src/primitives/RootInteger.cpp”
#include “TFile.h”
#include “TClassTable.h”
#include
using SctArchiving::RootInteger;
int main(){
{
TFile f (“blah.root”,“UPDATE”);
SctArchiving::RootInteger i(3);
i.Write(“myob”);
f.Close();
}
gClassTable->Print();
{
TFile g (“blah.root”,“READ”);
gDirectory->pwd();
gDirectory->ls();
RootInteger* i = (RootInteger*) g.FindObjectAny(“myob”);
std::cout << “PTR=” << i << std::endl;
std::cout << “VAL=” << *i << std::endl;
}
}
RootInteger looks like:
#ifndef SCTARCHIVING_ROOTINTEGER_H
#define SCTARCHIVING_ROOTINTEGER_H
#include “TObject.h”
namespace SctArchiving{
class RootInteger : public TObject{
public:
RootInteger() : value(0) {;}
RootInteger(int val) : value(val) {;}
void operator= (const RootInteger& rhs) {value=rhs.value;}
virtual char* GetClassName(){return “SctArchiving::RootInteger”;}
operator int(){ return value;}
virtual ~RootInteger();
private:
int value;
ClassDef(RootInteger,1);
};
}
#endif
RootInteger.cpp looks like:
#include "RootInteger.h"
SctArchiving::RootInteger::~RootInteger() {}
ClassImp(SctArchiving::RootInteger)
The LinkDef file looks like:
#ifdef CINT
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ namespace SctArchiving;
#pragma link C++ class SctArchiving::RootInteger;
#endif