Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!usc!rutgers!att!dptg!ulysses!andante!alice!shopiro From: shopiro@alice.UUCP (Jonathan Shopiro) Newsgroups: comp.lang.c++ Subject: Re: True Virtual Summary: Destructors can never be pure virtual Message-ID: <10424@alice.UUCP> Date: 1 Feb 90 17:35:33 GMT References: <4800082@m.cs.uiuc.edu> <4924@drutx.ATT.COM> <10382@alice.UUCP> <4982@drutx.ATT.COM> Organization: AT&T Bell Laboratories, Murray Hill NJ Lines: 25 Kim Tran wants to know why he can't have a pure virtual destructor, that is class Foo { virtual ~Foo() = 0; // error }; The reason is that whenever an object is destroyed, the destructors for all its base classes are executed. The pure virtual syntax says that the function will never be called, but its name is a legitimate function name so the compiler tries to call it in the destructor of the derived class. Instead just write an empty destructor, e.g., class Foo { virtual ~Foo() {}; // okay }; -- Jonathan Shopiro AT&T Bell Laboratories, Warren, NJ 07060-0908 research!shopiro (201) 580-4229