Fabien Costantini wrote: >> Fabien Costantini wrote: >> >> [ Mike Sweet wrote ] >>>> IIRC we can't do this since a virtual copy() that calls copy(w,h) >>>> will call the wrong copy(w,h) due to a side-effect of how C++ handles >>>> such things. >>> Here's a little demonstrator of what I am explaining:
>>> [ ... snip ... ] >>> So any non virtual method calling a virtual method will call the right >>> derived class method (here B::copy(int, int) >> Okay, that works. But what is the side effect, if A::copy() is >> virtual? I get the same result. Wrong example? >> >> Albrecht > In fact, it will also work because any message sent to an object is resolved > into a call deducted dyna,ically from its virtual method table (VMT) which > contains a ref to itself and the correct pointers to methods (this in c++, > self in java). I know how virtual functions work, you don't need to explain _that_ ;-) > Anyway, what matters here is that it _will_ work perfectly the way described > it (so even if copy() is not virtual). No, not really. Of course you are right, if it works, then it's okay. But: you and Mike talked about a side effect that it wouldn't work if A::copy() would be virtual. As if this was sure. My understanding was that it should work anyway. Thus I'm curious what would be different if A::copy() would be virtual. Is this a side effect (bug?), maybe only of some compilers, or is it well-known and documented behavior? If it is not, we don't need to discuss ... Albrecht _______________________________________________ fltk-dev mailing list [email protected] http://lists.easysw.com/mailman/listinfo/fltk-dev
