「左」と「右」があいまいであるというコンパイルエラーが発生します。
間違った場所で左、右を宣言しましたか?
- メイン内で宣言しても役に立ちません
- 関数定義をメインの上に移動しても役に立ちません
これをどのように修正しますか?
最小テストケース:
#include <iostream>
using namespace std;
int left = 0, right = 0;
int main()
{
cout << left;
cout << right;
}
あげてるよ:
prog.cpp: In function ‘int main()’:
prog.cpp:6:13: error: reference to ‘left’ is ambiguous
prog.cpp:3:5: error: candidates are: int left
In file included from /usr/include/c++/4.7/ios:43:0,
from /usr/include/c++/4.7/ostream:40,
from /usr/include/c++/4.7/iostream:40,
from prog.cpp:1:
/usr/include/c++/4.7/bits/ios_base.h:918:3: error:
std::ios_base& std::left(std::ios_base&)
prog.cpp:7:13: error: reference to ‘right’ is ambiguous
prog.cpp:3:15: error: candidates are: int right
In file included from /usr/include/c++/4.7/ios:43:0,
from /usr/include/c++/4.7/ostream:40,
from /usr/include/c++/4.7/iostream:40,
from prog.cpp:1:
/usr/include/c++/4.7/bits/ios_base.h:926:3: error:
std::ios_base& std::right(std::ios_base&)