I have an error, please help

O get this error: Jump to case label [-fpermissive]
crosses initialization of 'std::string a'

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
   switch(place)
            {
                case 1:
                string a = "X";
                break;
                case 2:
                string b = "X";
                break;
                case 3:
                string c = "X";
                break;
                case 4:
                string d = "X";
                break;
                case 5:
                string e = "X";
                break;
                case 6:
                string f = "X";
                break;
                case 7:
                string g = "X";
                break;
                case 8:
                string h = "X";
                break;
                case 9:
                string i = "X";
                break;
            }
Hello SKREFI,

With out more code it is hard to say what is happening and hard to duplicate the error. What jumps out at me is the string a = "X";. I wonder if you are trying to redefine the variables here?

Try defining the variables out side of the switch and make the case statements just a = "X"; and see what happens.

Hope that helps,

Andy
Topic archived. No new replies allowed.