Tuesday, November 23, 2010

[C++]

Learned something new today.

If you get the "jump to case label" error in g++. This is caused when you don't have brackets in a switch-case but are trying to instantiate variables within the case statement.

switch( num )
{
case 1:
int a;
...
break;
....

Bad.

switch (num)
{
case 1:
{
int a;
....
}

Good.

No comments: