Code:
#include<iostream>
using namespace std;
int move=0;
void main()
{
++move;
}
##Error: "move" is ambiguous
How do I overcome this?
Code:
#include<iostream>
using namespace std;
int move=0;
void main()
{
++move;
}
How do I overcome this?
Stop typing using namespace std;
It happens because you injected a huge amount of symbols from namespace std
into the global namespace, then happened to use one of them. std
is big, and any header can include any other. Simply don't using namespace std;
.
If you must, do it locally in a function, or even better using std::what_you_need;
explicitly locally in a function.
Just try to use ::
before variable name, means from global namespace.
Correct code:
#include<iostream>
using namespace std;
int move=0;
int main()
{
++::move;
return 0;
}
Or
#include<iostream>
using namespace std;
int move=0;
int main()
{
using ::move;
++move;
return 0;
}