Basic namespace doubt

S

Subhransu

Hi All,

Just wanted to know if there is any difference between,

using namespace MyNamespace;

and

using namespace ::MyNameSpace;

Regards,
Subhransu
 
A

Alf P. Steinbach /Usenet

* Subhransu, on 16.06.2011 09:46:
... if there is any difference between,

using namespace MyNamespace;

and

using namespace ::MyNameSpace;

Yes. The "::" is the global namespace. The first directive might refer to some
nested MyNamespace.


Cheers & hth.,

- Alf
 
S

Saeed Amrollahi

* Subhransu, on 16.06.2011 09:46:





Yes. The "::" is the global namespace. The first directive might refer tosome
nested MyNamespace.

Cheers & hth.,

- Alf

Hi
If MyNamespace is a global level namespace, I believe there is
no difference between those two statements. Consider the namespace
std:
using namespace std;
using namespace ::std;
I think the second one is rather verbose, or more elaboration.

Regards,
--Saeed Amrollahi
 

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
473,768
Messages
2,569,575
Members
45,054
Latest member
LucyCarper

Latest Threads

Top