解决问题:
[Error] reference to xx is ambiguous
解决思路:
(1)错误代码:
int n,m,count;
count++;
count=0;
if(count>(n+1)/2)
{
tot++;
}
count=0;
if(count>(n+1)/2)
{
tot++;
}
(2)错误原因:
翻译:对 xx 的引用是模糊的。
这句话翻译出来后应该差不多解决问题了,这里说引用模糊,就是说在程序中出现了两个变量,但在代码中只出现了一个变量,就是说与C++内置函数重名。比如说这个地方count与map的成员函数count重名。
(3)问题解决:
int n,m,Count;
Count++;
Count=0;
if(Count>(n+1)/2)
{
tot++;
}
Count=0;
if(Count>(n+1)/2)
{
tot++;
}
通常将首字母大写,或重命名即可。