Path: utzoo!utgpu!watserv1!watmath!att!dptg!ulysses!andante!alice!shopiro From: shopiro@alice.UUCP (Jonathan Shopiro) Newsgroups: comp.lang.c++ Subject: Re: Pure virtual destructors Summary: Abstract base classes exist as sub-objects of their derived classes. Message-ID: <10461@alice.UUCP> Date: 10 Feb 90 19:18:30 GMT References: <4800082@m.cs.uiuc.edu> <7180012@hpfcbig.SDE.HP.COM> Organization: AT&T Bell Laboratories, Murray Hill NJ Lines: 24 In article <7180012@hpfcbig.SDE.HP.COM>, jenings@hpfcbig.SDE.HP.COM (Byron T. Jenings Jr.) writes: > I was trying to specify: > > This is an abstract base class that cannot exist, and so has nothing > but pure virtual functions. Since it cannot exist, it has no > destructor, so there's obviously no base class destructor for derived > classes to call. The summary says it all. Objects of the virtual base class do exist, as subobjects of instances of any derived class. It would be easy to check if a base class has a pure virtual destructor, and skip the call, but it is often the case that the compiler has to generate some code in the destructor and there would be no place to put it if the destructor were pure virtual. Probably the best thing would have been to generate an error message immediately upon seeing a pure virtual destructor instead of letting it get to a link failure. So use an empty destructor. It can be inline or not as you like. The situation with duplicated vtables is much improved in C++ 2.0 over 1.2 (and it will get beter in the future), so I would recommend trying it both ways to see which you like better. -- Jonathan Shopiro AT&T Bell Laboratories, Warren, NJ 07060-0908 research!shopiro (201) 580-4229