RE: [ROOT] TObject inheritance and assignment operator

From: Masaharu Goto (gotom@hanno.jp)
Date: Tue Apr 06 2004 - 13:57:40 MEST


Hello John,

If you inherit from TObject, you have to define explicitly an assignment
operator.  That was a very old story, so I do not remember exactly,  but
I thought there was a problem if you
do not do that.   At least, it will complicate the situation.

Consider you have class inheritance tree and not all of them having
explicit assignment operators, for the part there is explicit one, you
must use it. For the other part, you can memcpy.  But, you can not
memcpy the whole.  It is especially advisable not to use default
assignment operator if you have pointer member.

This is not a hard limit of Cint. But, please define explicit assignment

operator if you inherit from TObject.

Thank you
Masa Goto


-----Original Message-----
From: John Pretz [mailto:pretz@umdgrb.umd.edu] 
Sent: Tuesday, April 06, 2004 7:33 AM
To: Philippe Canal
Cc: Masaharu Goto; roottalk@pcroot.cern.ch
Subject: RE: [ROOT] TObject inheritance and assignment operator


Philippe,

Thanks for the reply.  There are one or two sentences in there that make

me think that you didn't catch the problem.  Let me clarify:
 
> This a known hard limititation of CINT.  Currently the behavior of
> interpreted classes inheriting from compiled classes is incorrect in 
> many ways (hence the warning that you can sometime see).
I _am_ using compiled classes exclusively.  I have seen that warning 
about limitations from inheriting from precompiled classes and want to 
avoid it.  What I want to do is use my precompiled classes from the 
interpreter.  If I define the assignment operator, it can pick it up.
The 
problem comes when I leave gcc to make the assignment operator (by just 
not declaring one).  And this only seems to fail when I'm inheriting
from 
TObject.  If I inherit from my own base class its fine.
 
> Namely CINT does not know how to modify the virtual table to take in 
> account the interpreted part.  Hence as far as any compiled code is 
> concerned, your object is limited to the compiled part.  It is likely 
> that the 'default assignment operator' will not work. (I suppose it 
> could but ...)
Again, it is all compiled except the macro that uses the classes.  I
don't 
think the virtual table must be touched after the library is loaded.

I'm fine if this limitation still exists, I just wanted to make sure the

problem was understood.

Thanks,

John

-- 
---------------Visit my webpage!---------------------
---------http://umdgrb.umd.edu/pretz-----------------



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:07 MET