c++ - When to use an elaborated type specifier -
is there particularly reason choose use elaborated type specifier? example, in circumstances, 1 required use template or typename keywords disambiguate dependent template or type.
but can't think of examples occur such enumeration. take following code example:
enum foo { a, b }; void bar(foo foo); void baz(enum foo foo); why might choose use syntax baz() provides on bar() (or vice-versa)? there ambiguous case?
there no reasons use such specifiers, unless dealing situation when name hidden name of different "kind". example, legal declare variable named foo after enum declaration, since, speaking informally, object names , type names live in independent "namespaces" (see 3.3/4 more formal specification)
enum foo { a, b }; int foo; after int foo declaration, bar declaration become invalid, while more elaborate baz declaration remain valid.
Comments
Post a Comment