Switch Statement - main.cpp:275: error: crosses initialization of `CardNds ssmain'

Where do I place brakets when making a declaration within a switch statement?

Here is an example of my code:

1
2
3
4
5
6
7
8
9
10
switch(round){ 
case 1:
scoreMatch scoreMatchTurnMain= ScorePlayerMatch(matchTurnMain.odds[0], matchTurnMain.odds[1], matchTurnMain.odds[2], matchTurnMain.odds[3], matchTurnMain.odds[4], matchTurnMain.odds[5], matchTurnMain.pairCard, matchTurnMain.secPairCard, matchTurnMain.threeKindCard, highC, lowC, matchTurnMain.overCard);
							
case 2: 
scoreMatch scoreMatchTurnMain= ScorePlayerMatch(matchTurnMain.odds[0], matchTurnMain.odds[1], matchTurnMain.odds[2], matchTurnMain.odds[3], matchTurnMain.odds[4], matchTurnMain.odds[5], matchTurnMain.pairCard, matchTurnMain.secPairCard, matchTurnMain.threeKindCard, highC, lowC, matchTurnMain.overCard);

default:
break;
}


These are function calls for a struct (scoreMatch), stored as new struct (scoreMatchTurnMain), from function (ScorePlayerMatch())

Any ideas?
1
2
3
4
5
6
7
8
case 1:
    {
        scoreMatch scoreMatchTurnMain=//...
    }
case 2:
    {
        scoreMatch scoreMatchTurnMain=//...
    }
The same will happen if you try to do this:
1
2
3
4
5
if (rand()&1)
    goto label;
T some_object;
label:
//... 
much thanks...
Topic archived. No new replies allowed.