Why std::cout instead of simply cout?

后端 未结 7 1921
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-30 02:17

I get these error messages for all cout and endl:

main.cc:17:5: error: ‘cout’ was not declared in this scope
main.cc:17:5: note: sugges         


        
7条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-30 02:54

    "std" is a namespace used for STL (Standard Template Library). Please refer to https://en.wikipedia.org/wiki/Namespace#Use_in_common_languages

    You can either write using namespace std; before using any stl functions, variables or just insert std:: before them.

提交回复
热议问题