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

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

    You never have to declare using namespace std; using it is is bad practice and you should use std:: if you don't want to type std:: always you could do something like this in some cases:

    using std::cout;
    

    By using std:: you can also tell which part of your program uses the standard library and which doesn't. Which is even more important that there might be conflicts with other functions which get included.

    Rgds Layne

提交回复
热议问题