Hello, I have a class that I would like to save to a TFile and so needs to inherit from TObject. I want to use the same class in a non-ROOT, pure c++ program compiled with g++. The code below runs fine when compiled in ROOT (.L RunData.C+) but when linking outside ROOT, it returns an “undefined reference to `vtable for RunData’” error.
My understanding is that this error has something to do with declaring a function but not implementing it? Any suggestions will be appreciated!
RunData.hh
#ifndef __RunData__
#define __RunData__
#include "TObject.h"
class RunData : public TObject {
public:
RunData();
ClassDef(RunData, 1); // Test Class
private:
Double_t polarization_;
Double_t alignment_;
};
#include <iostream>
#include "RunData.hh"
ClassImp(RunData)
using namespace std;
RunData::RunData() {
cout << "I am here." << endl;
polarization_ = 0.94;
alignment_ = 0.234;
}
So again, this runs fine within ROOT but fails outside ROOT. Any ideas on how to make this work?