初級 › error: 'cout' is not a member of 'std' の原因と直し方 › パターン4
error: 'cout' is not a member of 'std' の原因と直し方
#include <iostream> を書き忘れたまま std::cout や std::endl を使ったときに出るエラーです。
1 ___________________ ^ 2 int main() { 3 std::cout << "result" << std::endl; 4 return 0; 5 }
main.cpp:3:10: error: 'cout' is not a member of 'std'
空欄を埋めてコンパイル・実行を通す
std::coutを使うにはiostreamのインクルードが必要です。忘れるとcoutがstdのメンバとして見つかりません。
次の問題