Why std::cout instead of simply cout?

后端 未结 7 1922
佛祖请我去吃肉
佛祖请我去吃肉 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条回答
  •  感情败类
    2021-01-30 02:48

    In the C++ standard, cout is defined in the std namespace, so you need to either say std::cout or put

    using namespace std;
    

    in your code in order to get at it.

    However, this was not always the case, and in the past cout was just in the global namespace (or, later on, in both global and std). I would therefore conclude that your classes used an older C++ compiler.

提交回复
热议问题