Using std Namespace

前端 未结 16 899
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-22 04:57

There seem to be different views on using \'using\' with respect to the std namespace.

Some say use \' using namespace std\', other say don\'t but rathe

16条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-22 05:34

    If you don't have a risk of name conflicts in your code with std and other libraries you can use :

    using namespace std;
    

    But if you want know precisely the dependancy of your code for documentation or there is a risk of name conflicts use the other way :

    using std::string;
    using std::cout;
    

    The third solution, don't use these solutions and write std:: before each use in code brings you more security but, maybe a little heaviness in the code...

提交回复
热议问题