初級 › 'cout' was not declared エラー(std::忘れ)の原因 › パターン5
'cout' was not declared エラー(std::忘れ)の原因
#include <iostream> はしているのに、std::を付けずにcoutやendlをそのまま使ったときに出るエラーです。
1 #include <iostream> 2 int main() { 3 int n = 42; 4 std::cout << n ____________; ^ 5 return 0; 6 }
main.cpp:4:23: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
空欄を埋めてコンパイル・実行を通す
coutにstd::を付けていても、endlの方に付け忘れると同じ種類のエラーが個別に起こります。
次の問題