union , enum and struct (and I believe that class too) together have separate "name buckets" (which have nothing to do with C ++ namespaces!) from common identifiers. This becomes understandable in C because you must prefix the names with struct , etc.
I don't have one for C ++, but this is from the C standard:
6.2.3 Name spaces of identifiers If more than one declaration of a particular identifier is visible at any point in a translation unit, the syntactic context disambiguates uses that refer to different entities. Thus, there are separate name spaces for various categories of identifiers, as follows: β label names (disambiguated by the syntax of the label declaration and use); β the tags of structures, unions, and enumerations (disambiguated by following any32) of the keywords struct, union, or enum); β the members of structures or unions; each structure or union has a separate name space for its members (disambiguated by the type of the expression used to access themember via the . or -> operator); β all other identifiers, called ordinary identifiers (declared in ordinary declarators or as enumeration constants).
typ1232
source share