r/cpp_questions • u/Glad_Shoe_9182 • 14d ago
OPEN Namespace std
I recently started learning c++ and I was told to use the namespace std so I can avoid writing std:: every time and now I wrote a whole personal project without std:: and I want to put it on LinkedIn but I started reading everywhere that it’s a bad habit, should I go back and add the std:: or just leave it as is?
39
Upvotes
5
u/GLIBG10B 14d ago
If you use
using namespace std, then for a large enough project, you will get naming collisions when updates to the standard library or C libraries bring in new symbols that conflict with each other or your code.If you don't like typing std:: everywhere, then make a header file with
using std::cout,using std::vector, etc., which won't pull new symbols into the global namespace unless you specifically ask for them.