Consider the following example:
#include <iostream>
void foo(class B, B *b);
B *c; //OK
int main(){ }
The Standard N4296::3.3.2/7.1 [basic.scope.pdecl]
— for a declaration of the form
class-key attribute-specifier-seqopt identifier;
the identifier is declared to be a class-name in the scope that contains the declaration
, but according to N4296:3.3.4/1 [basic.scope.proto]
In a function declaration, or in any function declarator except the declarator of a function definition (8.4), names of parameters (if supplied) have function prototype scope, which terminates at the end of the nearest enclosing function declarator.
So, the class B
should have been introduced in the function prototype scope. And the scope of B
should have been up to the end of the foo
's declarator. But the name is visible in the global scope. Why?