There is a quote from sec. 3.3.1 / 4 of the working draft N3797:
Given a set of ads in a single declarative region, each of which indicates the same unqualified name,- exactly one declaration declares a class name or an enumeration name that is not a typedef name, and other declarations must refer to the same variable or enumerator, or all relate to functions and function templates;
Given a set of ads in a single declarative region, each of which indicates the same unqualified name,
- exactly one declaration declares a class name or an enumeration name that is not a typedef name, and other declarations must refer to the same variable or enumerator, or all relate to functions and function templates;
We can declare a type name enumseveral times in one declarative scope:
enum
enum A; // declared first time, the other declaration with the same // unqualified name shall all refer to the same variable or enumeration. enum A; // This and the other declarations shall all refer to the that enumeration extern int A; // Fail, now enum A is hidden and we can access it // via elaborated-type-specifier only
I'm confused. Can you explain this behavior? I would like to find relevant links to the current working draft.
n3797 3.3.1/4:
, ,- , ;- , , ; .
, ,
- , ;
- , , ; .
, , . . S7.2 , :
enum A : int; // declaration (and it is an enumeration name) enum A : int; // refers to the same entity enum struct A; // declaration (and it is an enumeration name) enum struct A; // refers to the same entity enum A {}; // declaration (and it is an enumeration name) enum A {}; // refers to the same entity
.
extern int A; // declaration hides enumeration name void f() { A j = A.a; // illegal. A is hidden int k = A; // legal }
. n3797 3.3.10/2:
(9.1) (7.2) , , , . , , ( ) , , , , .
, A . , ?
: ? , , , , A? - . S7.2/6 :
A
, , (3.3.2) enum-base ( ), . , , } , .
, A , . 7.2/3 :
opaque-enum , . [: , opaque-enum, . enumspecifier. -end note] . , , , .
, , , , , , .
, , , , .
, . (enum) - , enum A; , . . 1. :enum A { a, b, c };, 3 {a, b, c}, - , - A. : enum NAME; NAME var1; NAME var2;:enum { a, b, c };, , , ..
enum A;
enum A { a, b, c };
enum NAME; NAME var1; NAME var2;
enum { a, b, c };
Source: https://habr.com/ru/post/1540949/More articles:Как эффективно нормализовать данные, в то время как INSERTing в SQL-таблицу (Postgres) - pythonJava repeats the final object a second time - javaHow to call compat_ioctl or unlocked_ioctl? - linux-device-driverTraversing a binary tree to list all permutations of Fibonacci values - c ++Gulp, html templates and fragment loading - underscore.jsDisplay square Tkinter.Button's? - pythonWhy doesn't ng-click = "test ()" work, but onclick = "angular.element (this) .scope (). Test ()" does? - angularjsProfile hit graphs in python - pythonStriped Captured Photo - c #Linking to a Listbox control unit with SQLite, image bytes are stored in a C # database - c #All Articles