Linked Questions
56 questions linked to/from Using std Namespace
3460
votes
39
answers
1.3m
views
What's the problem with "using namespace std;"?
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 ...
72
votes
5
answers
97k
views
std::string vs string in c++ [duplicate]
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 ...
64
votes
2
answers
314k
views
What is the use of "using namespace std"? [duplicate]
What is the use of using namespace std?
I'd like to see explanation in Layman terms.
4
votes
4
answers
4k
views
C++ "using std::<type>" vs calling std::<type> every time [duplicate]
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 ...
3
votes
3
answers
600
views
C++ namespaces - "using" or explicitly stated? [duplicate]
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
...
1
vote
2
answers
828
views
Is it ok to write "using std::vector;" in the header? instead of writing std::vector<int>v every time? [duplicate]
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 ...
0
votes
1
answer
590
views
QT Creator does not recognize STL types for new projects [duplicate]
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 ...
1
vote
1
answer
184
views
What is the difference of using std:: vs. not using it in C++? [duplicate]
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?
2439
votes
15
answers
294k
views
Should 'using' directives be inside or outside the namespace in C#?
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 ...
257
votes
16
answers
233k
views
How do you properly use namespaces in C++?
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 ...
191
votes
8
answers
270k
views
How to redirect cin and cout to files?
How can I redirect cin to in.txt and cout to out.txt?
147
votes
9
answers
127k
views
"using namespace" in c++ headers [duplicate]
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 ...
71
votes
5
answers
4k
views
Why is my log in the std namespace?
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 ...
18
votes
2
answers
7k
views
C++ Standard Library: How to write wrappers for cout, cerr, cin and endl?
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
#...
30
votes
5
answers
67k
views
Global variable "count" ambiguous
#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];
...