virtual base class

Pasha Murat (murat@cdfsga.fnal.gov)
Mon, 5 Oct 1998 10:02:49 -0500 (CDT)


Florian Schopper writes:
>
> Dear Rooters,
>
> first of all, Cint is GREAT for testing hardware. It's so useful to be
> able to call memberfunctions interactively and watch what happens at the
> outputs.
>
> -------------------------------------------------------
> I have a problem with virtual base classes:
>
> Everything works fine, when MAdc and MTrigger are derived from
> MDaq WITHOUT virtual,
>
> //****************************
> class MDaq : public TObject
> { ........ClassDef(MDaq,0) }
>
> class MAdc : public virtual MDaq
> { ........ClassDef(MAdc,0) }
>
> class MTrigger : public virtual MDaq
> { ........ClassDef(MTrigger,0) }
> //******************************
>
> but as is, I get the compiler error:
>
> MAdc_Cint.cxx: In function `class TBuffer & operator >>(class TBuffer &, class MAdc *&)':
> MAdc_Cint.cxx:424: cannot cast up from virtual baseclass `MDaq'
>
> Is the problem that there is only ONE TObject for several
> derived classes? But to derive MAdc directly from TObject
> additionally doesn't work either.
>

Hi Florian:
you're touching a serious issue which has been discussed a lot on this
list. In 2 words: an interpreted class can't be derived from a compiled one
because the virtual tables of the compiled classes are compiler-dependent.
This is where the things stand now.
-pasha.