* Ole Nielsby:
> The standard (last prelim ed.) says:
>
> ---quote---
> 3.3.7 - Name hiding [basic.scope.hiding]
>
> -2- A class name (class.name) or enumeration name (dcl.enum) 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 the same name, the class or enumeration name is hidden wherever
> the object, function, or enumerator name is visible.
> ---quote---
>
> Why is this?
Presumably you can still refer to the class, say, X, by writing "class
X" or "struct X". Don't know about the enum. If would be more
difficult if the class name hid the function, object or enumerator name.
> What's the point of having a class/enum and a function with
> the same name?
Presumably because old C placed names in different "namespaces", like
struct names in struct namespace where you had to write "struct X",
unless you used a typedef, so, sort of backwards compatibility with C.
> Any examples of practical use?
None that I can think of.
Cheers, & hth.,
- Alf
|