String is ambiguous (I've looked online no answers)

So my compiler (Visual Studio Express 2015) says that the string left, right, and empty are ambiguous, I've looked online on google and everything and I can't come up with an answer on how to make it so that I can pass that as an argument or even use it in an if statement or anything if someone could help me to know why I would be so grateful, thanks :)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#pragma once

#include <iostream>
#include <string>
using namespace std;

//global variables
int tunnel_amount = 0;
string empty = "";
string left = "left";
string right = "right";
string straight = "straight";

//variable definitions
#define ta tunnel_amount

//function declarations
void direction_choice(int tunnel_amount, string direction, string direction1, string direction2);

void game_begin() {

	cout << "You are in a cave with two tunnels, one that goes left or right.";
	cout << "\nWhich direction would you like to go?";
	ta = 2;

	direction_choice(ta, left, right, empty);
}

void direction_choice(int tunnel_amount, string direction, string direction1, string direction2) {
	cout << "\nThere are " << tunnel_amount << " tunnels.";
	cout << "The tunnels go in the directions ";
		for (int i = 0; i < tunnel_amount; i++) {
			if (string::npos == true) {
				cout << "string is empty";
			}
		}
}
It's because you've committed the sin of writing this line of code.

using namespace std

Either change the variable names or add the std:: prefix to objects or methods in the std namespace.

what do you mean change the variable names?
This is why it's not recommended to use, like Cody said, using namespace std.

You can look up more info as to why, but basically in the namespace std, there are lots of functions. And if you have using namespace std, you can't name your other variables the function names that's in the std. Because c++ would get confused on which one you meant to use etc.

It get's much worse later when you're using many many different namespaces, with hundreds of functions each, and many of them has names that you would use for a variable like "right" or "left".

Not the best explanation but I hope it helped a bit. Basically, start using std:: instead. std::cout << "Hello World" << std::endl;
Thank you guys for the answers :) I get more now, so I'll start doing that
Topic archived. No new replies allowed.