using namespace std -- Does that make the exe huge?
(obviously talking about C++)
Should I just say using std::whatever instead of using namespace std;? I made a really small text-based game, and it was like 500k...I figured it'd be under 50, so is it because I said using namespace std? Also, I can just throw those using std::whatever declarations in a header, right?
it shouldn't matter, they're going to be linked the same way anyway(and, yes, it's ok use the std:: in headers)
using namespace std; is a compile-time resolution tool. It has no impact on linking or binary file size. Your large file size is most likely due to the size of the statically-linked iostream library.
Slightly off-topic, but here's A neat trick that I haven't tried in the .NET compilers to produce really small programs.
Quote:Original post by Bombario
Should I just say using std::whatever instead of using namespace std;?
In headers, you should preferably fully qualify all the names (std::vector, std::string, et cetera), and not use any using directives. The less you dump into the global namespace, the better. (using bla::whatever over using namespace bla is of course less bad, but as others have pointed out, the reasons have nothing to do with the size of the finished executable.)
You could always just stick your code in it's own namespace, and then you can pollute it all you want.
Quote:Original post by cowsarenotevil
Slightly off-topic, but here's A neat trick that I haven't tried in the .NET compilers to produce really small programs.
I tried that and my file got bigger. That was with a tic-tac-toe game, though. Using VC++ 2k3
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement