From: rdparker AT butlermfg DOT org (Parker, Ron) Subject: RE: Mark ~fhandler_base virtual? 27 Mar 1998 10:29:55 -0800 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="---- =_NextPart_000_01BD5899.0B850730" To: Larry Hall , "'cygwin32-developers'" This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------ =_NextPart_000_01BD5899.0B850730 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit The only size effect in declaring a destructor as virtual is that it lengthens an objects vtable by sizeof(void*), admittedly 4-bytes is not an issue. However, in a class that has no virtual functions it also adds a vtable to the class and a vtable pointer to all of the objects of that class. This increases the size of the objects by sizeof(void*). This is only becomes a memory issue for small classes that have a large number of instances. By all means if a class has subclasses that contain explicitly declared destructors, the superclass should have a virtual destructor. See my previous message for more information on the need of virtual destructors. -----Original Message----- From: Larry Hall [mailto:lhall AT rfk DOT com] Sent: Wednesday, March 25, 1998 8:04 AM To: Geoffrey Noer; cygwin32-developers AT cygnus DOT com Cc: noer AT cygnus DOT com Subject: Re: Mark ~fhandler_base virtual? At 06:39 PM 3/24/98 -0800, Geoffrey Noer wrote: >I've been cleaning up warnings generated by compiling cygwin32 with >-Wall. One of them is that fhandler.h declares virtual functions but >has a non-virtual destructor. > >Should I make ~fhandler_base virtual? I *think* it's not necessary >but wouldn't hurt either. The function set_name (which is the only >thing that calls new and thus needs the destructor) is only called by >fhandler_base functions. > >-- >Geoffrey Noer >noer AT cygnus DOT com > I haven't looked at fhandler_base but assuming its name is indicative of its function and the fact that there are virtual functions on this class, a virtual destructor is recommended. In general, if a class is a base class, its destructor should be virtual. Also, there is no harm in making a destructor virtual even if the class is not a base class (or isn't "yet"). Larry Hall lhall AT rfk DOT com RFK Partners, Inc. (781) 239-1053 8 Grove Street (781) 239-1655 - FAX Wellesley, MA 02181 http://www.rfk.com ------ =_NextPart_000_01BD5899.0B850730 Content-Type: application/ms-tnef Content-Transfer-Encoding: base64 eJ8+IjsPAQaQC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