🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #2961

Re: Calling qualified member functions: a question

#2961
From: 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. ]
Technical Details
Message-ID: <5-CPicOZcDB@faerber.muc.de>
Path: arc1-ca.pugleaf.net!newsxfer2.itd.umich.edu!agate!agate!matt

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!newsxfer2.itd.umich.edu!agate!agate!matt
From: claus@faerber.muc.de (Claus Faerber)
Newsgroups: comp.std.c++
Subject: Re: Calling qualified member functions: a question
Date: 21 Dec 1995 20:03:01 GMT
Organization: <none>
Approved: matt@Austern (Matt Austern)
Message-ID: <5-CPicOZcDB@faerber.muc.de>
NNTP-Posting-Host: austern.hip.berkeley.edu