Path: utzoo!attcan!uunet!tut.cis.ohio-state.edu!att!drutx!kvt From: kvt@drutx.ATT.COM (TranKV) Newsgroups: comp.lang.c++ Subject: Pure Virtual Destructors Message-ID: <5033@drutx.ATT.COM> Date: 6 Feb 90 22:34:04 GMT References: <4800082@m.cs.uiuc.edu> <4924@drutx.ATT.COM> <10382@alice.UUCP> <4982@drutx.ATT.COM> <10422@alice.UUCP> Reply-To: kvt@drutx.ATT.COM (TranKV) Organization: AT&T, Denver, CO Lines: 38 Commenting on PURE VIRTUAL DESTRUCTORS In article <10422@alice.UUCP> ark@alice.UUCP (Andrew Koenig) writes: .... >Therefore, it doesn't make sense to have a pure virtual >destructor, as it would preclude destroying objects not >only of that class but of any class derived from it. I might be ignorant here but to counter Andrew's comments: 1. "preclude destroying objects ... of that class" From C++ usage point of view, this is perfectly OK since the base class might just be a place holder (i.e. no data members declared in class definition; therefore nothing needs to be destroyed.) I understand that in C implementation, every C++ class requires some data; but as a C++ user, should I be required to be aware of its C implementation? 2. "... not only of that class but of any class derived from it." I don't understand this. As I understand C++, a VIRTUAL BASE destructor forces the VIRTUAL DERIVED class destructor to be called first (when the derived object is pointed at by a base class pointer), and then other destructors in the class hierarchy. If that's so, why a PURE virtual base class destructor would prevent the VIRTUAL DERIVED class destructor to be called? I'd assume everything works as expected except when it's the turn of the base class destructor when nothing will be done. But that's OK (see my argument above.) I'm confused. Besides, if pure virtual destructors don't really make sense, why Cfront doesn't flag it as errors but let linker complain about it? Kim Tran Bell Labs kvt@drutx.att.com