Jump to content
  • Advertisement

Archived

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

Graham

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!