View Single Post
Old 10-22-2003, 08:39 PM   #2 (permalink)
palin
Code Monkey
 
palin's Avatar
 
Join Date: Jan 2003
Posts: 57
palin is on a distinguished road
Code:
switch(paycode){
   case 1: //calculate pay
           break;
   case 2: //calculate pay
           break;
   default: std::cout << "you entered an                  in correct pay type";
           break;

}
The switch will execute any code between the case 1: and the break; statements.


This may have changed but yeah it used to be implemented as a series of if/else statements. Java does it as a jump table but they may have changed the way the compilier works. in any case its a cleaner neater looking way of doing instead of if else statements.
palin is offline   Reply With Quote