Best way to use std and where to put it

I need help on how using std. Is it good to put it as a (using namespace std);
or just put is as a std::(something);? If so do I need to put (using namespace std;) before the int main() or in the int main? Thanks.
Hi

Either way is exceptable but I think that most people prefer 'using namespace std',
You should put the using namespace at the top of file generally just under the #include
statements.

eg
1
2
3
4
#include <iostream>

using   namespace   std;



Hope this helps
Shredded
Putting using namespace std; globally defeats the entire point of using namespaces in the first place. It's fine for small, quick programs, but in larger projects it should be avoided.

I just made another post recently explaining why. Read this:

http://www.cplusplus.com/forum/general/33646/#msg180967
Thanks Disch. This was something that was confusing me by looking at several tutorials. Some said to use using namespace std; while others said to use std::something. Like you said, both are fine in smaller applications, and your explanation makes sense. Finally, something is starting to make sense....
Topic archived. No new replies allowed.