Domanda

What part of the standard describes how entity does determine for the declared name? For instance

int foo(){ return 1; }

int main()
{
    int foo(); //I know that this foo denotes the "global" foo.
}

How it's occuring?

È stato utile?

Soluzione

In the C++11 standard, section 3.5p6 states

The name of a function declared in block scope and the name of a variable declared by a block scope extern declaration have linkage. If there is a visible declaration of an entity with linkage having the same name and type, ignoring entities declared outside the innermost enclosing namespace scope, the block scope declaration declares that same entity and receives the linkage of the previous declaration.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top