leo@atcmp.nl (Leo Willems) (10/04/90)
In par. 12.4 (last part) of E&S the difference between a virtual/static destructor call is clearified. The virtual call syntax is not accepted by all C++ compilers I have access to, the most current version is Comeau's 2.1 port for the 3b2/600. class X { public: X(){ cout << "X::X()\n"; } virtual ~X(){ cout << "X::~X()\n"; } }; void h(X& a) { a.~X(); // virtual..... but generates syntax error. a.X::~X(); // static...... compiles, and behaves virtual!! } Should this program compile? If so are there already compilers that do? Thanks Leo BTW, what is the meaning of the 'extern gg(X&)' in the E&S example, it's not a simple typo (s/gg/h/) because the returntypes are different?
kaiser@ananke.stgt.sub.org (Andreas Kaiser) (10/05/90)
In a message of <Oct 04 11:21>, 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