Sunday, 15 July 2012

c++ - Example of function prototype scope -



c++ - Example of function prototype scope -

there definition of function prototype scope (3.3.4/1 n3797):

in function declaration, or in function declarator except declarator of function definition (8.4), names of parameters (if supplied) have function prototype scope, terminates @ end of nearest enclosing function declarator.

can illustration described rule?

here simple example

int a; void f( int a, int );

the compiler issue error sec parameter because name coincides name of first parameter. compiler study there redefinition of name a. same name defined twice in same scope.

or example

struct {}; void f( int a, struct );

the first parameter name hides construction name sec parameter defined using elaborated name of structure.

c++ function

No comments:

Post a Comment