RE:virtual base class

Masaharu Goto (MXJ02154@nifty.ne.jp)
Tue, 06 Oct 1998 20:08:00 +0900


Florian,

>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'm very happy to hear this. I made Cint in convenience for hardware control
experiments. So, it is the best match to use cint in DAQ hardware control
programming.

Above the virtual base problem,
This is purely the C++ limitation. I guess you do something like below.

void f() { // f() is compiled
TBuffer x;
MDaq* p=new MAdc; // THIS DOES NOT WORK.
//MAdc* p=new MAdc; // THIS WORKS
x >> p;
}

You can not upcast from virtual base class in C++.
In this aspect, ROOT and CINT can do nothing.

Masaharu Goto

----------------------------------------
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.