Towers of Hanoi

code is giving me the error "no suitable conversion function from string to int exist" on Move(a, b) function. also im not sure if my tower moving is correct

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
void Move(int e, string x, string y, string z)
{
	if (e ==1)
	{
	cout << "Move disk from tower " << x << " to tower " << z << endl;
	}
	else
		cout<< "Move disk from tower " << x << " to tower " << y << endl;

}
	


void Hanoi(int n, string a, string b, string c)
  { 
       if (n == 1)  
          Move(a,c);
       else  
          Hanoi(n-1,a,c,b);
          Move(a,b);   
          Hanoi(n-1,c,b,a);
       
   }

int main()
{
	int numofdisk;
	cout << " *******WELCOME TO TOWERS OF HANOI******* " << endl;
	cout << "Please specify the number of disks" << endl;
	cin >> numofdisk;
	Hanoi(numofdisk, "A", "B", "C");
	system("Pause");
	return 0;

}
Hi @keyko18,

1
2
3
4
5
6
7
//function header
void Move(int e, string x, string y, string z)
//function call
Move(a,c);

First parameter should
be integer 


Topic archived. No new replies allowed.