From 2138484916616655477
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,4e0e65235aa5eceb
X-Google-Attributes: gidf78e5,public
From: Christopher Eltschka <celtschk@physik.tu-muenchen.de>
Subject: Re: pointer to member derivation question
Date: 1999/06/26
Message-ID: <377391F5.C8A41F3A@physik.tu-muenchen.de>#1/1
X-Deja-AN: 494075055
Content-Transfer-Encoding: 7bit
Approved: Fergus Henderson <fjh@cs.mu.oz.au>
References: <vgvk8swxj97.fsf@ms.com> <7ktjmc$95f$1@nnrp1.deja.com>
X-Original-Date: Fri, 25 Jun 1999 16:28:05 +0200
X-Accept-Language: German/Germany, de-DE, German, de, en
Content-Type: text/plain; charset=us-ascii
X-Complaints-To: news@news.unimelb.edu.au
X-Trace: izvestia.its.unimelb.edu.au 930385841 17979 128.250.29.16 (26 Jun 1999 08:30:41 GMT)
Organization: [posted via] Leibniz-Rechenzentrum, Muenchen (Germany)
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUAN3SPneEDnX0m9pzZAQFwUwGAltEBBr65HtnxqP+xKM4GwiNioXBb3onf p6bNold3ZvdVbSLikzUQDstC39MMbsFi =0OKw
Mime-Version: 1.0
NNTP-Posting-Date: 26 Jun 1999 08:30:41 GMT
Newsgroups: comp.std.c++

Jim Hyslop wrote:
> 
> In article <vgvk8swxj97.fsf@ms.com>,
>   Colin Rafferty <craffert@ms.com> wrote:
> > Hi-
> >
> > I have the following code, and it makes sense to me that it should
> > work, but different compilers have different thoughts on the subject.
> >
> >     class Base { /* ... */ };
> >
> >     class Derived : public Base { /* ... */ };
> >
> >     class Holder
> >     {
> >     public:
> >       Derived _derived;
> >     };
> >
> >     void f()
> >     {
> >       Base Holder::* elt = &Holder::_derived;
> >     }
> Er, I hate to point out the obvious, but doesn't elt require an *object*
> to work on, i.e.:
> 
> void f()
> {
>    Holder h;
>    Base Holder::* elt = &h._derived;
> }

No. &Holder::_derived gives a Derived Holder::*.
AFAIK your code wouldn't be legal at all, even if the obvious
conversion were allowed, since &h._derived is of type Derived*,]
not Derived Holder::*.

> 
> BTW, you should avoid using leading underscores in identifiers, since
> they are reserved for compiler and STL usage.

While I agree with the "should", you are not completely right
here. Only identifiers using double underscores and identifiers
beginning with underscore and capital letter are reserved in
every scope; all other identifiers beginning with a single
underscore are only reserved in global scope and in namespace
std.
However, the implementor of your compiler may have the
same misunderstanding, and therefore it's a good idea to
avoid them anyway.
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]



