初級 › error: 'x' was not declared in this scope の原因と直し方 › パターン1
error: 'x' was not declared in this scope の原因と直し方
宣言していない変数を使ったときに出るエラーです。
1 #include <iostream> 2 int main() { 3 int total = 5; 4 std::cout << ______ << std::endl; ^ 5 return 0; 6 }
main.cpp:4:18: error: 'toal' was not declared in this scope; did you mean 'total'?
空欄を埋めてコンパイル・実行を通す
totalとtoalは文字が入れ替わっただけの別名です。g++は似た名前の宣言済み変数を見つけると「did you mean」で提案してくれますが、実際に直すのは自分です。
次の問題