初級 › error: 'cout' is not a member of 'std' の原因と直し方 › パターン2
error: 'cout' is not a member of 'std' の原因と直し方
#include <iostream> を書き忘れたまま std::cout や std::endl を使ったときに出るエラーです。
1 ___________________ ^ 2 int main() { 3 int x = 5; 4 std::cout << x << std::endl; 5 return 0; 6 }
main.cpp:4:10: error: 'cout' is not a member of 'std'
空欄を埋めてコンパイル・実行を通す
変数を出力する場合でも、iostreamをインクルードしていなければstd::coutは使えません。
次の問題