home bbs files messages ]

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 33,062 of 33,346   
   Francis Glassborow to Stuart   
   Re: [Solved] sequence of inheritance fro   
   19 May 13 07:01:04   
   
   From: francis.glassborow@btinternet.com   
      
   On 19/05/2013 08:04, Stuart wrote:   
      
   > Well, I learned something too. I didn't know that the compiler is   
   > allowed to lay out the base class members in a different order than   
   > the one that is given in the class definition. So if one has to   
   > achieve some memory layout, one has to take special care if one of   
   > the base classes contains virtual methods.   
      
   { Quoted signature removed -mod }   
      
   Well a class that includes at least one virtual function is likely to   
   be more vulnerable, but, IIUC, the implementation is at liberty to lay   
   out a derived class' base classes anyway it likes. There are, IIRC,   
   some limitations on the relationship between a pointer to the derived   
   class and a pointer to the first base class in the declaration of the   
   derived class.   
      
   Multiple inheritance (particularly when it involves virtual bases) is   
   quite tough to implement. Indeed, when virtual bases (rather than just   
   polymorphic base classes) necessitates that the layout of base class   
   sub-objects may vary down the inheritance tree. In simple terms, do   
   not make assumptions about the layout of classes that include the   
   potential for multiple inheritance.   
      
   Regards   
   Francis   
      
      
   --   
         [ 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