I would like to create an interface (C++ abstract base class and daughter classes, derived from the base class) and implement it into ROOT script. How can I do this?? Some basic templates of the .h and .cxx files are below:
That’s more a C++ question than a ROOT one. You can have a look at the many C++ tutorials available on the web. That said, what you wrote seems correct.
vlad ~/HEP/root_classes_exmple % root -l testscript.cxx
root [0]
Processing testscript.cxx...
IncrementalExecutor::executeFunction: symbol '_ZN12DerivedClass5WriteEv' unresolved while linking [cling interface function]!
You are probably missing the definition of DerivedClass::Write()
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol '_ZN12DerivedClass6CreateEv' unresolved while linking [cling interface function]!
You are probably missing the definition of DerivedClass::Create()
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol '_ZN12DerivedClass4FillEv' unresolved while linking [cling interface function]!
You are probably missing the definition of DerivedClass::Fill()
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol '_ZTV12DerivedClass' unresolved while linking [cling interface function]!
You are probably missing the definition of vtable for DerivedClass
Maybe you need to load the corresponding shared library?
root [1]
both of your solutions are work. First one is the simplest to realize, but it can be messy in case of some sophisticated classes and projects. In this case the second variant can be a solution (to compile shared libraries).