🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Claus Faerber Thu, 21 Dec 1995 20:03
Re: Calling qualified member functions: a question
#2961
Author: Claus Faerber
Date: Thu, 21 Dec 1995 20:03
58 lines
2090 bytes
sanjayp@hpcll169.cup.hp.com (15 Dec 95):

>
> Hi nettors,
>
>   I would like to know if the following program is legal or not:
>   //------------------------------------------------------
>   class X {
>     ~X() { ... }
>   };
>
>
>   class A {
>     class X : public ::X {
>      ~X() { ... }
>     };
>     void foo() {
>       X o1;
>
>       o1.::X::~X();  // we want the dtor for the first X to
>                      // be called, how else to specify that?
>     }
>   };

You *can't* specify, which dtor is called first, if you called the ::X::~X  
dtor first, then it would be called again in X::~X again!
And you can NEVER call a destructor explicitly!!

>   According to the April ANSI C++ draft the construct o1.::X::~X() seems
> illegal because
>
>    postfix-expression:
>               :
>    postfix-expression . id-expression
>
>   And id-expression cannot start with '::' .

What you're trying is to tell the compiler, that it should treat o1 as a ::X.
You can do this by:
        (::X)o1.method();

>    If that is the case, should the standard be modified to allow this
> kind of construct?

** NO! **

===========================================================================
 Claus Andre Faerber                                <claus@faerber.muc.de>
 Mitterfeldstrasse 20 * D-83043 Bad Aibling * Germany * fax: +49-8061-2057
===========================================================================
## CrossPoint v3.1 ##


---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads