Path: utzoo!attcan!uunet!husc6!cmcl2!rutgers!bellcore!faline!thumper!ulysses!andante!alice!ark From: ark@alice.UUCP (Andrew Koenig) Newsgroups: comp.lang.c++ Subject: Re: Virtual Destructors? Message-ID: <8590@alice.UUCP> Date: 23 Dec 88 13:53:12 GMT References: <5568@cbmvax.UUCP> Organization: AT&T Bell Laboratories, Liberty Corner NJ Lines: 30 In article <5568@cbmvax.UUCP>, daveh@cbmvax.UUCP (Dave Haynie) writes: > I'm pretty new to this C++ game, but I've already run into something that > doesn't make sense. Perhaps this is already fixed -- I'm using Lattice > C++ V1.00 on the Amiga, which is based on cfront V1.1a. In any case, I > can't figure out why in the world destructors aren't virtual. If you want a destructor to be virtual, make it virtual: class A { public: A(); virtual ~A(); // and so on }; Be aware that there is a fairly widespread bug that causes virtual destructors not to work quite right unless all derived classes have explicit destructors, even if the destructors are empty. So: class B: public A { public: // stuff ~B() { } // empty destructor // other stuff }; But aside from that, virtual destructors work just fine. -- --Andrew Koenig ark@europa.att.com