Why std::cout instead of simply cout?

后端 未结 7 1906
佛祖请我去吃肉
佛祖请我去吃肉 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:55

    It seems possible your class may have been using pre-standard C++. An easy way to tell, is to look at your old programs and check, do you see:

    #include 
    

    or

    #include 
    

    The former is pre-standard, and you'll be able to just say cout as opposed to std::cout without anything additional. You can get the same behavior in standard C++ by adding

    using std::cout;
    

    or

    using namespace std;
    

    Just one idea, anyway.

提交回复
热议问题