Topic: Name Hiding
Author: clamage@eng.sun.com (Steve Clamage)
Date: 1999/03/29 Raw View
"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 ]
Author: "pmucci" <pmucci@innova.net>
Date: 1999/03/28 Raw View
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
?
is it legal to do this ?
class X
{
char X;
};
thanks
---
[ 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 ]