#### Archived

This topic is now archived and is closed to further replies.

# using namespace std error

This topic is 5402 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I just started up a new console program using VC++ 6.0 and the line, using namespace std; generates an error. The compiler says that std does not exist or is not a namespace, can anyone help me with this? Go on an Intense Rampage

##### Share on other sites
Are you including at least one standard header before the using namespace declaration? If so, which one?

"Sneftel is correct, if rather vulgar." --Flarelocke

##### Share on other sites
#include <iostream>#include <fstream>#include <sstream>#include <iomanip>#include <cstdio>#include <cstdlib>#include <cstring>#include <ctime>#include <cmath>//STL#include <string>#include <vector>#include <sort>#include <list>#include <iterator>#include <find>useing namespace std;

and many more, the list goes on and on.

##### Share on other sites
Try "using namespace std;" (note that is one less e than your version)

##### Share on other sites
alternitively don''t use "using namespace std;" it''s not strictly necessary. all it does is save you the time of writing std:: before std variable types. I find that not using it is not big deal:

std::string foo;

v.

string foo;

-me

##### Share on other sites
quote:
Original post by Palidine
alternitively don''t use "using namespace std;" it''s not strictly necessary. all it does is save you the time of writing std:: before std variable types. I find that not using it is not big deal:

std::string foo;

v.

string foo;

-me

..although in OP''s original case, since std is not found, "std::string" will also likely generate an error.

The problem definately lies in what you are "#include"-ing...

##### Share on other sites
And putting "using namespace std;" in a header file is considered bad practice, because it defeats the whole purpose of namespaces. It''s all up to you, though.

##### Share on other sites
You can do individual usings for the elements that you use most and that you know that you will avoid name conflict with. In that way, you retain the namespace''s safty.

##### Share on other sites
Thanks for the help. The problem was that I was that my include statement was, #include <iostream.h>, instead of #include <iostream> If you put the .h then you dont need std, but without the .h you do.

##### Share on other sites
quote:
Thanks for the help. The problem was that I was that my include statement was, #include <iostream.h>, instead of #include <iostream> If you put the .h then you dont need std, but without the .h you do.

But remember that the .h headers are deprecated, always use the headers that don''t end in .h.

1. 1
2. 2
Rutin
21
3. 3
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633736
• Total Posts
3013602
×