#include<bits/stdc++.h>
using namespace std;
int count;
int main()
{
int k;
cin>>k;
count=k;
cout<<count;
return 0;
}
我正在尝试更改main函数中的'count'(全局变量)的值,但是在C++中获取'count'的引用是不明确的
错误。 但是同样的代码在C中很好用,请帮助我。
删除“using namespace std;”,将std::添加到cin和cout中,这样就可以了。 因为std::count存在:https://en.cppreference.com/W/cpp/algorithm/count,所以编译器在std::count和变量计数之间存在歧义,因为您使用了“using namespace std”。