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

后端 未结 12 2167
抹茶落季
抹茶落季 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:24

    All the files in the C++ standard library declare all of its entities within the std namespace.
    e.g: To use cin,cout defined in iostream

    Alternatives:

    using std::cout;
    using std::endl;
    cout << "Hello" << endl;
    std::cout << "Hello" << std::endl;

提交回复
热议问题