What requires me to declare “using namespace std;”?

后端 未结 12 2190
抹茶落季
抹茶落季 2020-12-17 10:55

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+

12条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-17 11:15

    First of all, this is not required in C - C does not have namespaces. In C++, anything in the std namespace which includes most of the standard library. If you don't do this you have to access the members of the namespace explicitly like so:

    std::cout << "I am accessing stdout" << std::endl;
    

提交回复
热议问题