I did generate a dictionary (using rootcling though). However, a dictionary is only useful for the interpreter, right?
I’m not using the interpreter but a compiled code using my custom derived class. When calling the Write() function, the MyClass object is saved rather than the TH2D object from which it inherits.
the dictionaries for ROOT6 are used for I/O only: interactivity at the prompt (i.e. interpretation), unlike in the ROOT5 case, can happen without dictionaries.
The fact that you perform I/O operations from the prompt, a macro or compiled code is identical for ROOT. The dictionary has to be available in form of a loaded library.
The moment you ask ROOT to write a MyClass instance, ROOT does so. I see two possibilities:
Change the design of your class and encapsulate the TH2D rather than inheriting from it. You can have a Write method which just forwards to the TH2D::Write method.