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

  • Home
  • SEARCH
  • 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 4017770
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:54:07+00:00 2026-05-20T09:54:07+00:00

I am working on a c++ library which is split up into multiple namespaces.

  • 0

I am working on a c++ library which is split up into multiple namespaces. Since I am trying to avoid the “using” directive in header files I am forced to do the alternative “namespace::class” for variables, returns and parameters. As you can imagine this could get messy. So, I tried putting the using statement inside a namespace decloration (see below) and that seemed to do the trick, It doesn’t appear to be visible in files including this file.

namespace Project
{
    namespace Utility { class A; }

namespace System
{
    using Utility::A;

    class B
    {
        A *a;   // instead of Utility::A *a
    };
}
}

My question is, would it be okay to do this instead?

  • 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-20T09:54:08+00:00Added an answer on May 20, 2026 at 9:54 am
    // your header
    
    namespace Project
    {
        namespace Utility { class A; }
    
    namespace System
    {
        using Utility::A;
    
        class B
        {
            A *a;   // instead of Utility::A *a
        };
    }
    }
    
    // end your header
    
    class A {};
    
    int main()
    {
        using namespace Project::System;
        A a;
    }
    
    test.cpp:25:5: error: reference to 'A' is ambiguous
        A a;
        ^
    test.cpp:20:7: note: candidate found by name lookup is 'A'
    class A {};
          ^
    test.cpp:9:20: note: candidate found by name lookup is 'Project::System::A'
        using Utility::A;
                       ^
    1 error generated.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to get a multiple upload library working for my Codeigniter based
I'm working on a thread library which implement user level threads (i have something
I'm trying to get the Boost library working in my C++ projects in Eclipse.
I'm working using scriptaculous library. However I'm facing some issues with inclusion of the
I'm working on a library which implements the actor model on top of Grand
I am working on a library which needs to make use of the common
My problem is this: I am trying to implement a C++ library which can
I have written a C library which consists in a few .h files and
I am using a search library which advises keeping search handle object open for
I have been working for some time on a library which performs numeric calculations.

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.