Article View: comp.std.c++
Article #2472Virtual functions and destructors
From: Chris Parker
Date: Thu, 09 Nov 1995 06:08
Date: Thu, 09 Nov 1995 06:08
32 lines
2089 bytes
2089 bytes
As a result of problems I'm having with C++ program execution, I need to examine what the C++ standard says with respect to virtual destructors. I understand these are a special case of virtualness and there are special rules associated with how compilers are to support them. Does C++ require you to declare your destructor virtual whenever you declare any other member function in the class to be virtual? Is it acceptable according to the standard for the destructor to be the only virtual member in the class? Is virtualness inherited by destructors? Does C++ automatically make all applicable superclasses also have virtual destructor if they don't already? If virtualness of destructors is inherited, then what is supposed to happen to in the case where one of our subclasses uses multiple inheritance and one of the other trees leading to the subclass doesn't declare destructors to be virtual anywhere? If anyone has any knowledge regarding what the C++ standard says about virtual destructors, I'd appreciate it if you could answer any of the questions that you can. I have all these situations occuring in a program I wrote, and I don't understand why it is behaving as it is and the answers to those questions would explain a lot of things for me. Thanks for any input you can provide. Chris Parker parker@cs.WPI.EDU --- [ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu. Contact address: std-c++-request@ncar.ucar.edu. The moderation policy is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID:
<47r71q$cp0@bigboote.WPI.EDU>Path:
arc1-ca.pugleaf.net!in1.uu.net!bounce-backShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back Date: 09 Nov 95 06:08:33 GMT Approved: fjh@cs.mu.oz.au From: parker@WPI.EDU (Chris Parker) Newsgroups: comp.std.c++ Subject: Virtual functions and destructors X-Original-Date: 8 Nov 1995 21:22:02 GMT Organization: Worcester Polytechnic Institute Message-ID: <47r71q$cp0@bigboote.WPI.EDU> X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUBMKGbJeEDnX0m9pzZAQHY7AGAgWcj+fU5gITEfxIovQt2YYVEUBROQcrQ s73Q04huf6p3fNtPu9CpHAypWn/cCjgl =Jbnh