![](/img/trans.png)
[英]Error: Identifier “cout” is undefined. <iostream> included and using namespace std;
[英]cout and endl are undefined even though using std:: and <iostream>
我正在嘗試輸入簡單的“ Hello World!” 代碼,但未定義cout和endl。
#include<iostream>
#include "stdafx.h"
int main()
{
std::cout << "Hello World!" << std::endl;
}
結果是出現以下錯誤:“'cout':不是'std'的成員,請注意:請參見'std'的聲明,'cout':未聲明的標識符”,與endl相同。 請幫忙。
您在#include語句中缺少空格: #include<iostream>
這是正確的方法: #include <iostream>
完整代碼:
#include <iostream>
#include "stdafx.h"
int main()
{
std::cout << "Hello World!" << std::endl;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.