This question may be a duplicate, but I can’t find a good answer. Short and simple, what requires me to declare
using namespace std;
in C++ programs?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Since the C++ standard has been accepted, practically all of the standard library is inside the std namespace. So if you don’t want to qualify all standard library calls with
std::, you need to add the using directive.However,
is considered a bad practice because you are practically importing the whole standard namespace, thus opening up a lot of possibilities for name clashes. It is better to import only the stuff you are actually using in your code, like