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,415 of 33,346    |
|    Pete Becker to All    |
|    Re: Is destructor automatically be virtu    |
|    25 Aug 11 15:54:53    |
   
   From: pete@versatilecoding.com   
      
   On 2011-08-25 12:32:23 +0000, Daniel Krügler said:   
      
   > On 2011-08-25 01:44, linq936 wrote:   
   >   
   >> class Base {   
   >> public:   
   >> virtual void do_sth() = 0;   
   >> };   
   >>   
   >> class D {   
   >> public:   
   >> virtual void do_sth() {}   
   >>   
   >> ... some other things ...   
   >> };   
   >>   
   >> int main()   
   >> {   
   >> Base* p = new D();   
   >> p->do_sth();   
   >> delete p;   
   >> return 0;   
   >> }   
   >>   
   >> We write above sort of code a lot, if the destructor generated by   
   >> compiler is not virtual, there will be memory leak.   
   >>   
   >> Can you confirm?   
   >   
   > I can confirm that you might have a memory leak, if you rely on that   
   > assumption ;-)   
      
   You also might have many other things. The behavior of the program is   
   undefined.   
      
   --   
    Pete   
   Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The   
   Standard C++ Library Extensions: a Tutorial and Reference   
   (www.petebecker.com/tr1book)   
      
      
    [ 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