Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.c++.moderated    |    Moderated discussion of C++ superhackery    |    33,346 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 31,695 of 33,346    |
|    Ulrich Eckhardt to All    |
|    Re: Covariant virtual function result ty    |
|    25 Nov 11 12:30:15    |
      From: ulrich.eckhardt@dominolaser.com              Am 25.11.2011 08:25, schrieb Yordan Naydenov:       > On 2011-11-24 02:40, Lorenzo Caminiti wrote:       >> ry* ryp = yp->f(); // calls y::f       >> rx* rxp = xp->f(); // calls y::f but returns rx* instead of ry*       >       > // Nope! calls y::f() [...] and interprets the memory layout       > // the returned pointer pointed to as that of an object of       > // type rx [...].              While the gist of this is true, there is one minor fault in your       statement. The memory does not get interpreted differently, but the       pointer to "y" is adjusted so that it points to the "x" base subobject.              The difference between the two memory addresses is zero in the example       Lorenzo gave, but if you imagine multiple nonempty baseclasses it       becomes clear that only one of the base subobjects can start at the same       address as the overall object.              The way you wrote it sounds a bit as if bad (implementation-defined or       undefined) things could happen, but all this works correctly without you       having to care for it.                     Greetings!              Uli                     --        [ See http://www.gotw.ca/resources/clcm.htm for info about ]        [ comp.lang.c++.moderated. First time posters: Do this! ]              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca