Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3601118
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:34:53+00:00 2026-05-18T20:34:53+00:00

namespace Stuff { class Sprite { }; class Circle : Stuff::Sprite { }; }

  • 0
namespace Stuff
{
    class Sprite
    {
    };

    class Circle : Stuff::Sprite
    {
    };
}

Will this work, or will this look for Stuff::Stuff::Sprite?

edit: forgot some semicolons.

edit 2: I’m accepting @Omnifarious’ answer because once he edited it with @Vlad’s help, it was the most complete answer. thanks also to @Vlad.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T20:34:53+00:00Added an answer on May 18, 2026 at 8:34 pm

    It will work if you put in the ; after the class definitions. But it will not work in quite the way you expect. First, it tries to figure out what namespace you’re talking about. First it will looks for ::Stuff::Stuff, and when it doesn’t find it, it then looks for the namespace ::Stuff. It finds that namespace, so it then looks in that namespace for Sprite and finds your class.

    If you have an unanchored namespace, it looks for that namespace path in the current namespace, then in the enclosing namespace, then in the enclosing enclosing namespace… etc… until it gets to the top level namespace.

    See this question of mine:

    • Why does everybody use unanchored namespace declarations (i.e. std:: not ::std::)?

    In my opinion, people ought to be a lot more careful than they are about referring to namespaces. Hardly anybody ever uses a root anchored namespace specification, even when they should be because they really do mean a specific absolute namespace and not a name relative to the current namespace.

    Here are a couple of interesting cases:

     1 namespace Bar {
     2
     3 class A {
     4 };
     5
     6 } // end namespace ::Bar
     7
     8 namespace Foo {
     9
    10 class A {
    11 };
    12
    13 Foo::A joe; // Refers to the A declared on line 10
    14
    15 namespace Foo {
    16 }
    17
    18 Foo::A fred; // Error, finds ::Foo::Foo and doesn't find A there.
    19 ::Foo::A fred; // Works and refers to the A declared on line 10
    20
    21 Bar::A barney; // Works, and refers to the A declared on line 3
    22
    23 namespace Bar {
    24
    25 class A {
    26 };
    27
    28 } // end namespace ::Foo::Bar
    29
    30 Bar::A wilma; // Works, and refers to the A declared on line 25
    31 ::Bar::A betty; // Also works, and refers to the A declared on line 3
    32 ::Foo::Bar::A dino; // Also works, and refers to the A declared on line 25
    33 } // end namespace ::Foo
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use the ofstream class to write some stuff to a file,
I have a small namespace containing some type definitions, which I use to make
Suppose I've got the following program: namespace ReflectionTest { public class Example { private
I've got a scenario like the following: class criterion { // stuff about criteria...
// ... snipped includes for iostream and fusion ... namespace fusion = boost::fusion; class
Namespace are pretty cool: with them, you can organize your libraries and you can
in the System.Linq namespace, we can now extend our IEnumerable's to have the Any()
I place using namespace in a view code behind but i can't call any
My schema specifies a namespace, but the documents don't. What's the simplest way to
In Microsoft's UnitTesting namespace ( Microsoft.VisualStudio.TestTools.UnitTesting ) there are AssemblyInitialize and AssemblyCleanup attributes you

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.