Linked Questions

3460 votes
39 answers
1.3m views

I have heard using namespace std; is wrong, and that I should use std::cout and std::cin directly instead. Why is this? Does it risk declaring variables that share the same name as something in the ...
akbiggs's user avatar
  • 35.4k
72 votes
5 answers
97k views

Possible Duplicates: Why is 'using namespace std;' considered a bad practice in C++? Using std Namespace I've been hovering around a bunch of different forums and I seem to see this pop up every time ...
OVERTONE's user avatar
  • 12.4k
64 votes
2 answers
314k views

What is the use of using namespace std? I'd like to see explanation in Layman terms.
Jarvis's user avatar
  • 647
4 votes
4 answers
4k views

Possible Duplicate: Using std Namespace Why is 'using namespace std;' considered a bad practice in C++? Let's say I'm using #include <iostream> in C++ and I'm making a print ...
limp_chimp's user avatar
  • 15.6k
3 votes
3 answers
600 views

Possible Duplicates: Why is ‘using namespace std;’ considered a bad practice in C++? Using std Namespace Is it just a matter of preference? Or is there a valid reason for preferring ...
Mawg's user avatar
  • 40.5k
1 vote
2 answers
828 views

Since, i got to know that writing "using namespace std;" in the header should be avoided. And now i find it pretty annoying to write "std::" before vector,string,cout,cin etc every ...
Lame Things's user avatar
0 votes
1 answer
590 views

I have an existing project where the STL types are recognized. However, when creating a new project none of the STL types are not recognized. For example in #include <string> string s; the ...
Jan Laloux's user avatar
1 vote
1 answer
184 views

Possible Duplicate: Using std Namespace I was just wondering if there was some reason to include std:: in some operations, like std::sort() for example. Is it because of possible overloading?
user avatar
2439 votes
15 answers
294k views

I have been running StyleCop over some C# code, and it keeps reporting that my using directives should be inside the namespace. Is there a technical reason for putting the using directives inside ...
benPearce's user avatar
  • 38.5k
257 votes
16 answers
233k views

I come from a Java background, where packages are used, not namespaces. I'm used to putting classes that work together to form a complete object into packages, and then reusing them later from that ...
Marius's user avatar
  • 59.2k
191 votes
8 answers
270k views

How can I redirect cin to in.txt and cout to out.txt?
updogliu's user avatar
  • 6,355
147 votes
9 answers
127k views

In all our c++ courses, all the teachers always put using namespace std; right after the #includes in their .h files. This seems to me to be dangerous since then by including that header in another ...
Baruch's user avatar
  • 22k
71 votes
5 answers
4k views

In the code below, I define a trivial log function. In main I try not to call it; I call std::log. Nevertheless, my own log is called; and I see "log!" on screen. Does anyone know why? I use G++ 4.7 ...
user2023370's user avatar
  • 11.3k
18 votes
2 answers
7k views

I do not like using namespace std, but I am also tired of having to type std:: in front of every cout, cin, cerr and endl. So, I thought of giving them shorter new names like this: // STLWrapper.h #...
Ashwin Nanjappa's user avatar
30 votes
5 answers
67k views

#include <algorithm> using namespace std; int count = 0, cache[50]; int f(int n) { if(n == 2) count++; if(n == 0 || n==1) return n; else if (cache[n] !=- 1) return cache[n]; ...
user avatar

15 30 50 per page