Reaching into the default namespace when using another namespace.

J

Jason Heyes

Can somebody tell me how to change only the main function below so that bar
in the default namespace is assigned 4 and not bar in namespace foo?

int bar;
namespace foo { int bar; }
using namespace foo;

int main()
{
bar = 4;
return 0;
}

Thanks a heap.
 
W

Woebegone

Jason Heyes said:
Can somebody tell me how to change only the main function below so that
bar in the default namespace is assigned 4 and not bar in namespace foo?

int bar;
namespace foo { int bar; }
using namespace foo;

int main()
{
bar = 4;
return 0;
}

Thanks a heap.
I think you want "::bar = 4;"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,184
Messages
2,570,973
Members
47,530
Latest member
jameswilliam1

Latest Threads

Top