初級 › error: 'cout' was not declared in this scope; did you mean 'std::cout'? の原因と直し方 › パターン2
error: 'cout' was not declared in this scope; did you mean 'std::cout'? の原因と直し方
#include <iostream> はしているのに、std::を付けずにcoutやendlをそのまま使ったときに出るエラーです。
1 #include <iostream> 2 int main() { 3 int x = 5; 4 _________ << x << std::endl; ^ 5 return 0; 6 }
main.cpp:4:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
空欄を埋めてコンパイル・実行を通す
g++は「did you mean 'std::cout'?」と修正候補まで示してくれますが、修正するのは自分自身です。
次の問題