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 32,455 of 33,346   
   Qi to Piotr Nycz   
   Re: Is this correct: virtual method of D   
   05 Jul 12 10:44:59   
   
   From: no@no.no   
      
   On 2012-7-5 7:01, Piotr Nycz wrote:   
   >   
   >   
   > Please answer: Is this correct, this g++ behavior? What C++ standard says   
   about that? Maybe it is undefined behavior?   
   >   
   > Please do not answer that I should not do such things. I just want to learn   
   something about C++ - examples are not from real project.   
      
   Didn't check what standard says.   
   But GCC is correct.   
   Whenever you call a virtual function in a constructor, it's always   
   that the function in current class is called.   
   There is no polymorphism behavior in constructor.   
   Reason? The virtual function table was not setup in the constructor yet.   
   So in constructor, the compiler treats all member function calls in the   
   class as non-virtual.   
      
   All above is what I understand, correct me if I'm wrong.   
      
      
   --   
   WQ   
      
         [ 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