Re: "using namespace std" causing soooo many errors
From: frank sinatra (frank_at_spamoff.net)
Date: 03/08/04
- Next message: Graeme Prentice: "Re: basic_string ref across dlls"
- Previous message: frank sinatra: "Re: + or += (was: why not use i++ instead of ++i in for()?)"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 8 Mar 2004 11:57:46 +0200
> The solution is to never, ever, ever put "using namespace std" in a
> header file. That means you expose all of std to all files that include
> this header file, and you end up with problems like the above.
> Namespaces are there for a reason.
#include <string>
namespace foo {
using std::string;
// ... mystuff ...
}
I do that without problems, I thought typedefs and using statements were
properly scoped. Using a whole namespace in similiar way with C++ standard
conformant compiler shouldn't bring out too much issues.. not that I would
recommend doing it, and naturally I would better avoid using same symbols
the std:: is using, ah, I see what this is about, sorry for wasting the
bandwidth. But atleast the GLOBAL namespace would be safe, until someone
decides to use namespace "bar" (the one inside which we would be using all
of the std..)
Just joking, I am not sorry, the point was that hand-picking some classes
like above can be handy now and then!
- Next message: Graeme Prentice: "Re: basic_string ref across dlls"
- Previous message: frank sinatra: "Re: + or += (was: why not use i++ instead of ++i in for()?)"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|