Basic namespace doubt

Discussion in 'C++' started by Subhransu, Jun 16, 2011.

  1. Subhransu

    Subhransu Guest

    Hi All,

    Just wanted to know if there is any difference between,

    using namespace MyNamespace;

    and

    using namespace ::MyNameSpace;

    Regards,
    Subhransu
    Subhransu, Jun 16, 2011
    #1
    1. Advertising

  2. * 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

    --
    blog at <url: http://alfps.wordpress.com>
    Alf P. Steinbach /Usenet, Jun 16, 2011
    #2
    1. Advertising

  3. On Jun 16, 12:43 pm, "Alf P. Steinbach /Usenet" <alf.p.steinbach
    > wrote:
    > * 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 tosome
    > nested MyNamespace.
    >
    > Cheers & hth.,
    >
    > - Alf
    >
    > --
    > blog at <url:http://alfps.wordpress.com>


    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
    Saeed Amrollahi, Jun 16, 2011
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. manasa sreenivas via .NET 247

    doubt about namespace google

    manasa sreenivas via .NET 247, May 15, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    566
    John Young
    May 15, 2004
  2. Bob Nelson

    doubt about doubt

    Bob Nelson, Jul 28, 2006, in forum: C Programming
    Replies:
    11
    Views:
    623
  3. Replies:
    0
    Views:
    557
  4. Peter Otten
    Replies:
    2
    Views:
    110
    Cousin Stanley
    Aug 10, 2013
  5. Terry Reedy
    Replies:
    0
    Views:
    114
    Terry Reedy
    Aug 10, 2013
Loading...

Share This Page