Problem2194--The call to function In the global namespace

2194: The call to function In the global namespace

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 334  Solved: 141
[Submit] [Status] [Web Board] [Creator:]

Description

Suppose we have the following namespace: namespace A { void f(int); //. . . } using namespace A; // In the global namespace void g() { f(‘a’); // calls A::f(int) } In the global namespace, the function g( ) calls f(‘a’). There is no problem here, f(‘a’) is unambiguously A::f(int). Now suppose at some later time, the following namespace grouping and using directive is inserted prior to the call to function f. namespace B { void f(char); //. . . } using namespace B; For convenience, all these are listed again. namespace A { void f(int); //. . . } using namespace A; namespace B { void f(char); //. . . } using namespace B; // In the global namespace void g() { f(‘a’); } In g(), to what does the call, f(‘a’) resolve? How could the code be modified so that the call still resolves to A::f(int)?

Output

::g() A::f(int) B::f(char)

Sample Output Copy

::g()
A::f(int)
B::f(char)

Source/Category

34