From 4240738830823254145
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,b3ca3c6f3bcbf52
X-Google-Attributes: gidf78e5,public
From: clamage@eng.sun.com (Steve Clamage)
Subject: Re: Name Hiding
Date: 1999/03/29
Message-ID: <7dmmsi$79o$1@engnews1.eng.sun.com>#1/1
X-Deja-AN: 460243731
Approved: Fergus Henderson <fjh@cs.mu.oz.au>
References: <922662362.701.60@news.remarQ.com>
X-Original-Date: 29 Mar 1999 02:00:50 GMT
X-Complaints-To: news@news.unimelb.edu.au
X-Trace: izvestia.its.unimelb.edu.au 922689481 17983 128.250.29.16 (29 Mar 1999 06:38:01 GMT)
Organization: Sun Microsystems Inc., Mountain View, CA
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUANv8fteEDnX0m9pzZAQG2MAF8DR1cqfkmOIvCLg1cys+ePqr4NGArk/mg 8LFgo0Kk+tgCAQiMMlNq4I52JRitAJ8f =ryJu
NNTP-Posting-Date: 29 Mar 1999 06:38:01 GMT
Newsgroups: comp.std.c++

"pmucci" <pmucci@innova.net> writes:

>3.3.7 [basic.scope.hiding]

>paragraph 2

>A class name (9.1) or enumeration name (7.2) can be hidden by the
>name of an object, function, or enumerator declared in the same scope.
>If a class or enumeration name and an object, function, or enumerator
>are declared in the same scope (in any order) with he same name,
>the class or enumeration name is hidden wherever the
>object, function, or enumerator name is visible.

>As far as classes go, does this paragraph refer specifically to class c-tors
>?

No. It doesn't apply to constuctors, because ctors don't have names.
(That's an odd provision of the standard introduced to make some
explanations easier.) When you declare, define, or invoke a
ctor, you do it by writing the name of the class. But that isn't
the name of a ctor, and if you look up the class name in the
class, you will not find a ctor.

>is it legal to do this ?

>class X
>  {
>    char X;
>  };

No. Chapter 9 paragraph 13 says 
=============================
If T is the name of a class, then each of the following shall have
a name different from T:
-- every data member of class T;
-- every member of class T that is itself a type;
-- every enumerator of every member of class T that is an enumerated
    type; and
-- every member of every anonymous union that is a member of class T.
=============================

That paragraph would seem to allow to allow function members having
the name of the class, but such a function must be a ctor.

--
Steve Clamage, stephen.clamage@sun.com
---
[ 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              ]



