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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:44:59+00:00 2026-05-27T11:44:59+00:00

To avoid scoping everything from the STL, you can type using namespace std; To

  • 0

To avoid scoping everything from the STL, you can type

using namespace std;

To avoid scoping only a few things, you can type:

using std::cout;  
using std::cin;

I want to write a library that acts the same way. However, instead of being able to include specific classes, I want to be able to include specific collections of functions.

So, for example, I code:

  • A collection of string functions
  • A collection of math functions

They are part of the same namespace, but I can include the chunks I want


This is sudo-ish code, but I think it gets my idea across:

namespace Everything{
    namespace StringFunctions{
        void str1(string & str);
        void str2(string & str);
        void str3(string & str);
        void str4(string & str);
        void str5(string & str);
    }

    namespace MathFunctions {
        void math1(int & num);
        void math2(int & num);
        void math3(int & num);
        void math4(int & num);
        void math5(int & num);
    }
}

then I want to be able to do something like:

#include "Everything.h"
using Everything::Stringfunctions;

int main(){

    str1("string"); //this works, I can call this!
    math1(111);     //compile error: I've never heard of that function!

    return 0;
}

Obviously this does not work, and I am kind of confused on how to divide up my library. I don’t want to make them classes and then have to use the “dot operator” everywhere, but I also don’t want to include a ton of header files.

Maybe I am going about this the wrong way. I hope everyone can help me take the right approach here.


EDIT:

It works by writing:

using namespace Everything::Stringfunctions;

This is very obvious now in hindsight.

  • 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-27T11:45:00+00:00Added an answer on May 27, 2026 at 11:45 am

    The way that you have written your library in the example that you gave is sufficient.

    People can get every function from the namespace Everything::Stringfunctions by using the directive using namespace Everything::Stringfunctions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

from the below question i sort of get how enums and namespace scoping works
After trying to avoid JavaScript for years, Iv started using Query for validation in
Should developers avoid using continue in C# or its equivalent in other languages to
How can you avoid circular dependencies when you're designing two classes with a producer/consumer
I'm trying to avoid a composite control or using and ASCX by extending an
To avoid having to repeat type parameter information when subclassing parameterized classes, I'm trying
To avoid reinventing the wheel, I am generating a form using CakePHP's form helper,
I'm trying to avoid dot notation at all costs, but I am learning from
Why should we avoid using class variables @@ in rails? Is there any security
I wish to avoid using css transitions. I have three divs of the same

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.