error C2082: redefinition of formal parameter 'i'

May 24, 2013 at 4:59am
could you please help me with this part.. it says error C2082: redefinition of formal parameter "i"

1
2
3
4
5
6
7
8
9
10
11
12
13
  void sorting(int x[], int i)
{
	int i, pass, hold;
	cout<< setw(4) << x[i];
	for (pass = 1; pass <SIZE; pass++)
		for (i = 1; i < SIZE - 1; i++)
			if(x[i] > x [i + 1])
			{
				hold = x[i];
				x[i] = x[i + 1];
				x[i + 1] = hold;
			}
			

Last edited on May 24, 2013 at 4:59am
May 24, 2013 at 5:07am
I believe it is because you declare i as a parameter on line 1 then redeclare it as a local variable one line 3. I would've expected hiding, but perhaps it is just an error.
May 24, 2013 at 8:09am
Websearch with the error message finds (among other things):
http://msdn.microsoft.com/en-us/library/k4h61sx8%28v=vs.80%29.aspx

The Visual Studio does have decent amount of documentation.
Topic archived. No new replies allowed.