Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!samsung!sol.ctr.columbia.edu!ira.uka.de!smurf!nadia!ananke!kaiser From: kaiser@ananke.stgt.sub.org (Andreas Kaiser) Newsgroups: comp.lang.c++ Subject: explicit virtual destructor call Message-ID: <27.270C3B5B@ananke.stgt.sub.org> Date: 5 Oct 90 07:18:03 GMT Organization: Ananke, Stuttgart, FRG Lines: 27 In a message of , Leo Willems (leo@atcmp.nl ) writes: LW> In par. 12.4 (last part) of E&S the difference between a virtual/static LW> destructor call is clearified. LW> The virtual call syntax is not accepted by all C++ compilers I have access to, LW> the most current version is Comeau's 2.1 port for the 3b2/600. LW> void h(X& a) LW> { LW> a.~X(); // virtual..... but generates syntax error. LW> a.X::~X(); // static...... compiles, and behaves virtual!! LW> } Interesting questions, since there is a side-effect, at least in Zortech C++. If I want to call a destructor in Zortech C++ explicitly, I have to use the full qualified name p->X::~X(); p->~X() is not possible. This is of importance in error handling, so it is absolutely necessary to provide a method of calling a virtual destructor virtual. What is the standard? Should it be possible to call p->~X() instead if p->X::~X() to get the virtual calling technique? If not, the latter MUST call the destructor virtual - there would be no other way. Gruss, Andreas