Afficher un message
Vieux 06/02/2008, 10h15   #1
Rahul
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut compilation error in switch case in c++

Hi Everyone,

I have the following program,

class A
{
int i;
};

int main()
{
switch(1)
{
case 1 :
// {
A obj;
printf("case 1\n");
// }
break;
case 2 :
A obj1;
printf("case 2\n");
break;
}
}


and when i compile, i get an compilation error, saying,

jump to case symbol
enters scope of non-POD 'A obj'

but if i remove the commented open and close brace, it works just
fine, could anyone clarify the exact reason of the compiler reporting
the error,

Thanks in advance!!!


  Réponse avec citation
 
Page generated in 0,05106 seconds with 9 queries