Reaching into the default namespace when using another namespace.

Discussion in 'C++' started by Jason Heyes, Nov 19, 2004.

  1. Jason Heyes

    Jason Heyes Guest

    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.
    Jason Heyes, Nov 19, 2004
    #1
    1. Advertising

  2. Jason Heyes

    Woebegone Guest

    "Jason Heyes" <> wrote in message
    news:419d568b$1$21280$...
    > 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;"
    --
    hth,
    Sean.
    Woebegone, Nov 19, 2004
    #2
    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. mortb
    Replies:
    7
    Views:
    2,843
    mortb
    Sep 1, 2004
  2. =?Utf-8?B?TGVpZg==?=

    Reaching/changeing Parameter Value in Java Applet

    =?Utf-8?B?TGVpZg==?=, Dec 6, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    1,590
    =?Utf-8?B?TGVpZg==?=
    Dec 7, 2004
  3. =?Utf-8?B?RXNyZWYgRFVSTkE=?=

    reaching the parent

    =?Utf-8?B?RXNyZWYgRFVSTkE=?=, Feb 24, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    364
    Andy Fish
    Feb 24, 2005
  4. mehmet canayaz
    Replies:
    1
    Views:
    322
    Victor Bazarov
    Feb 16, 2005
  5. Replies:
    2
    Views:
    178
Loading...

Share This Page