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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:52:30+00:00 2026-06-10T17:52:30+00:00

I attended a session in which it was taught that we should not use

  • 0

I attended a session in which it was taught that we should not use "using namespace std", instead do "std::cout" for using some call of the std namespace as this shall increase size of the binary

I tried verifying the same with the following experiment. The code & its output is as follows:-

    [Fooo@EXP]$ cat namespacestd.cpp
    #include<iostream>

    #ifdef STD
            using namespace std;
    #endif

    int main()
    {
    #ifndef STD
            std::cout<<"\n ==> Workign \n";
    #else
            cout<<"\n ==> Workign \n";
    #endif

    return 0;

    }


    [Fooo@EXP]$ time g++ -c namespacestd.cpp -DSTD

    real    0m0.246s
    user    0m0.215s
    sys     0m0.030s
    [Fooo@EXP]$ size namespacestd.o
       text    data     bss     dec     hex filename
        310       8       1     319     13f namespacestd.o  
    [Fooo@EXP]$ time g++ -c namespacestd.cpp

    real    0m0.258s
    user    0m0.224s
    sys     0m0.034s
    [Fooo@EXP]$ size namespacestd.o
       text    data     bss     dec     hex filename
        310       8       1     319     13f namespacestd.o

    [Fooo@EXP]$ time g++ -o namespacestd namespacestd.cpp -DSTD

    real    0m0.293s
    user    0m0.251s
    sys     0m0.042s
    [Fooo@EXP]$ size namespacestd
       text    data     bss     dec     hex filename
       1980     580     288    2848     b20 namespacestd
    [Fooo@EXP]$ time g++ -o namespacestd namespacestd.cpp

    real    0m0.274s
    user    0m0.239s
    sys     0m0.035s
    [Fooo@EXP]$ size namespacestd
       text    data     bss     dec     hex filename
       1980     580     288    2848     b20 namespacestd
    [Fooo@EXP]$

As I see from my experiment that

there is no effect on the size of binary

only

there is a difference in the compilation time.

Kindly correct me if my conclusions are flawed

Thanks

  • 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-06-10T17:52:31+00:00Added an answer on June 10, 2026 at 5:52 pm

    using namespace std shouldn’t affect binary size with most compilers. It should still be avoided for another reason:

    The namespace std is really big. There are literally thousands of identifier in there which are all in the scope of your program. This increases the likeliness of collisions with your own identifiers or identifiers from other libraries which can cause some nasty surprises.

    See also this related question: Why is "using namespace std" considered bad practice?

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

Sidebar

Related Questions

recently I attended a talk on data-mining,and I missed some points by the lecturer,which
A coding style presentation that I attended lately in office advocated that variables should
I use The MVC3 Helper to generate my Ajax form like this: @using (Ajax.BeginForm(Attended,
Recently I attended a lecture concerning some design patterns: The following code had been
We have a sports training camp which is regularly attended by various teams in
I have a database that logs when an employee has attended a course and
I have recently attended a presentation where guy showed that .NET obfuscated code can
Today, someone attended me to bad use of the return keyword in Java. I
I have recently attended an introductory course in using the iPhone SDK and the
Background: We are launching a event which would be attended by students from various

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.