0

Code:

#include<iostream>
using namespace std;
int move=0;
void main()
{
 ++move;
}

##Error: "move" is ambiguous

How do I overcome this?


Pravitha V
  • 3,308
  • 4
  • 33
  • 51
Pelican
  • 14
  • 3
  • Because of [`std::move`](http://en.cppreference.com/w/cpp/algorithm/move) and [`std::move`](http://en.cppreference.com/w/cpp/utility/move)? Try to avoid `using namespace std;` in your code. – Some programmer dude Aug 01 '17 at 12:53

2 Answers2

1

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.

Yakk - Adam Nevraumont
  • 262,606
  • 27
  • 330
  • 524
0

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;
}
ExModE
  • 1
  • 1