Essay
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)?
Correct Answer:

Verified
The call,f('a')resolves to B::f.The usin...View Answer
Unlock this answer now
Get Access to more Verified Answers free of charge
Correct Answer:
Verified
View Answer
Unlock this answer now
Get Access to more Verified Answers free of charge
Q25: You want to use only one name,funct1,from
Q26: Namespaces can be defined in pieces across
Q27: You can have a name spelled the
Q28: The include statement,#include <file.h> looks in the
Q29: The output from the following code is<br>"function".<br>(The
Q30: A namespace grouping requires a semicolon after
Q31: Use a namespace grouping to insert this
Q32: You can declare several names from a
Q33: Given the namespace groupings that contain
Q35: The include statement,#include "file.h" looks first in