Re: delete trouble

Masaharu Goto (gotom@hpyiddq.jpn.hp.com)
Mon, 07 Jul 1997 15:42:02 JST


Hello,

What Rene states is basically true, however, inheriting compilied class
in the interactive session should work as long as you do not use
virtual function. And even if you use it, it shouldn't crash.
I need to investigate.

Masaharu Goto

>
> Voropaev S.G. wrote:
> >
> > Dear ROOT people,
> > I have written the following code in file bad.cpp:
> > ---------------------------------------------------------
> > class der : public TObject
> > {
> > public:
> > der()
> > { printf("der constructor\n");}
> >
> > ~der()
> > { printf("der destructor\n"); };
> > };
> > void bad()
> > {
> > der *p = new der;
> > delete p;
> > }
> > ----------------------------------------------------------------
> > after start macro:
> > root [0] .x bad.cpp
> > I have this output:
> > der constructor
> > der destructor
> > and crash of ROOT program.
> >
> > If I change string "class der : public TObject" to "class der", all work fine.
> >
> > I use root 1.00/10 in Windows NT 4.0. It is legal to use class derived from
> > TObject
> > in interactive session? In documentation "Adding Your Own Classes to ROOT" I
> > find:
> >
> > "If you are only interested in interactive access to your classes via the
> > command line or macro processor you do not need to use the ClassDef and
> > ClassImp macros."
> >
>
> Classes created interactively cannot inherit from TObject or a compiled
> class in general. It would be very nice to have this possibility obviously.
> It turns out that this is highly system dependent because CINT has to know
> the VTBL specific to each compiler.
>
> Rene Brun
>