using namespace std; after #includes

using namespace std; after #includes

Post by Frank Birb » Sun, 01 Mar 2009 07:30:27


blargg schrieb:

Well, only for the function parameters. Because you can also put a
"using namespace" into a function scope or any local scope. I use this
quite often, for example in a function that uses a lot of std:: things
like algorithms. This is like a third alternative opposed to "global"
using namespace after the includes at the beginning of source, and not
using namespace at all.


[ See ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

1. Is 'using namespace std;' valid without 'namespace std {};' first?

2. #include <iostream> & "using namespace std;"

Hi all,

I just started learning this spreme language of VC++ using
version 7.0.9037 on Visual Studio .NET (a bit buggy since
this is Beta 1). From my previous post I learnt that I
should use <iostream> instead of <iostream.h>.

Here is my VERY SIMPLE code;
#include <iostream>

using namespace std;

int main (void)
cout << "Hello World!";
return 0;

The above-mentioned code works without a hitch, but if I
take out "#include <iostream>" directive or "using
namespace std;", the error message says, "error
C2065: 'cout' : undeclared identifier". Why do I need
both? I thought "std" embodies standard input and output
libraries and therefore I don't need #include directive...

Why can I NOT find "std" header file under \Microsoft
Visual Studio.NET\Vc7\include\? All the other header files
are in this "include" folder. Is this "std" something very
special??? Where can I find it?

What is your opinion in using "using namespace std;"
extravagantly? I read some articles saying that we can use
it for a small project, but not for a big one since it
might mask global variables scope unnecessarily (or
unexpectedly), in other words, they suggest
use "std::cout". What do you think?

Thanks for your time,
Tetsuya Oguma, Sydney, Australia

3. which headers to #include - std::ostream std::iostream std::iosfwd

4. Why there is just one namespace 'std' in the std library?

5. BCB2006: memset, std namespace, std header idempotence, bug?

6. Convert std::string to std::wstring using std::ctype widen()

7. Q: Convert std::string to std::wstring using std::ctype widen()

8. using namespace std

9. using namespace std;

10. what does using namespace std mean?

11. using namespace std?

12. why "using namespace std; " is not working?

13. using namespace std

14. Question about using namespace std