【问题标题】:cout and endl are undefined even though using std:: and <iostream>即使使用 std:: 和 <iostream>,cout 和 endl 也是未定义的
【发布时间】:2018-05-07 19:07:12
【问题描述】:

我正在尝试输入简单的“Hello World!”代码,但 cout 和 endl 未定义。

#include<iostream>
#include "stdafx.h"
int main()
{
    std::cout << "Hello World!" << std::endl;
}

原来的错误是:“'cout': is not a member of 'std', note: see declaration of 'std', 'cout': undeclared identifier”,和 endl 一样。 请帮忙。

【问题讨论】:

    标签: cout identifier endl


    【解决方案1】:

    #include 语句中缺少一个空格: #include&lt;iostream&gt;

    这是正确的方法: #include &lt;iostream&gt;

    完整代码:

    #include <iostream>
    #include "stdafx.h"
    int main()
    {
        std::cout << "Hello World!" << std::endl;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-08-04
      • 2019-03-05
      • 2017-05-13
      • 2020-03-19
      • 2015-05-21
      • 1970-01-01
      相关资源
      最近更新 更多