初級 › error: 'x' was not declared in this scope の原因と直し方 › パターン3
error: 'x' was not declared in this scope の原因と直し方
宣言していない変数を使ったときに出るエラーです。
1 #include <iostream> 2 int main() { 3 int width = 10; 4 int height = 20; 5 std::cout << (width * _______) << std::endl; ^ 6 return 0; 7 }
main.cpp:5:27: error: 'hight' was not declared in this scope; did you mean 'height'?
空欄を埋めてコンパイル・実行を通す
heightをhightと書き間違えると、コンパイラはそのような名前を知らないため即座にエラーにします。
次の問題