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 7508119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:37:24+00:00 2026-05-29T22:37:24+00:00

Assume having a C++ class. And there’s a namespace which should be visible only

  • 0

Assume having a C++ class. And there’s a namespace which should be visible only inside my class. What to do for that?

class SomeClass
{
    using namespace SomeSpace;

public:
    void Method1();
    void Method2();
    void Method3();
};

namespace SomeSpace
{
    /*some code*/
};
  • 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-29T22:37:25+00:00Added an answer on May 29, 2026 at 10:37 pm

    using namespace X; is called a using directive and it can appear only in namespace and function scope, but not class scope. So what you’re trying to do is not possible in C++. The best you could do is write the using directive in the scope of the namespace of that class, which may not be desirable.

    On second thought, though, analyzing your words,

    Assume having a C++ class. And there’s a namespace which should be
    visible only inside my class. What to do for that?

    I’d suggest something like the following, which I am not sure is what you want.

    class A
    {
    public:
        void Method1();
        void Method2();
        void Method3();
     
    private:
     
        class B
        {
           //public static functions here, instead of namespace-scope
           // freestanding functions.
           //these functions will be accessible from class A(and its friends, if any) 
           //because B is private to A
        };
    
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having a scenario where there are several subclasses which have got similar
I would assume there would be a convenience class somewhere where I could call
Assume following scenario: There is a WPF window, within a MVVM implementation. Having following
I am having trouble over simply assigning a value to a UI Button: //Assume
Having problems iterating. Problem has to do with const correctness, I think. I assume
Assume the following class: public class MyEnum: IEnumerator { private List<SomeObject> _myList = new
Assume that we have N erlang nodes, running same application. I want to share
Assume I have a class foo, and wish to use a std::map to store
Assume you have a list item, <li id=foo> which you want to fade from
I have a library which creates objects (instances of class A) and pass them

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.