初級 › error: 'cout' is not a member of 'std' の原因と直し方 › パターン3
error: 'cout' is not a member of 'std' の原因と直し方
#include <iostream> を書き忘れたまま std::cout や std::endl を使ったときに出るエラーです。
1 ___________________ ^ 2 int main() { 3 std::cout << 42 << std::endl; 4 return 0; 5 }
main.cpp:3:10: error: 'cout' is not a member of 'std'
空欄を埋めてコンパイル・実行を通す
数値リテラルを出力するだけの単純なコードでも、iostreamのインクルードが無ければ同じエラーになります。
次の問題