When to use an elaborated type specifier

There are no reasons to use such specifiers, unless you are dealing with the situation when the name is hidden by name of a different “kind”. For example, it is perfectly legal to declare a variable named Foo after the enum declaration, since, speaking informally, object names and type names live in independent “namespaces” (see 3.3/4 for more formal specification)

enum Foo { A, B };

int Foo;

After the int Foo declaration, your bar declaration will become invalid, while the more elaborate baz declaration will remain valid.

Leave a Comment