Ooooooooh. Now I see the practical use of it! Qwerty made it sound like a countdown. Well, now that that is cleared up, it is time to integrate it into my code.
Incidentally, I hit up Barnes and Noble for some tutorial books on C++ and only found books on C#. It would seem that C# is more expansive, but still uses a lot of syntax from C++, so it would be beneficial to learn C++ first. My question is, what does C# offer over C++ that would be more useful?
Also, take some sympathy on me for this question as I have oceans behind my ears given that I'm 14 and started 2 days ago. What,exactly, must be done to make something in C++ be more than text based? Is it possible? What programs would I need in addition if it is?
The result is a countdown if you arrange it in decending order and do NOT return/break from the higher numbers.
Usually, you will break or return(depending on the use) after every case, and in that situation if/else if/else works.
Here is a better example(I hope) somewhat like a roguelike.
A door can be broken by explosions, but a player can also kick a door down.
Both have the same result, but the player may fail to kick down the dor, and if they succeed, they get skill.
The diffrent cases are assumed to have been #defined elsewhere.
KICK_DOOR uses the "fall through" thing so that the program flow continues through DOOR_BROKEN, doing both.
The return; at the end of DOOR_BROKEN ensures that the program does NOT dontinue to do OTHER_ACTIONS, although break; would also have worked if there was something that had to be done after the switch() before the function return;s.
switch(n)
{
case KICK_DOOR:
if(failure)return;
do_some_skill_up_stuff();
case DOOR_BROKEN:
break_door();
return;
case OTHER_ACTIONS:
}
Edit:
The code is the same as
switch(n)
{
case KICK_DOOR:
if(failure)return;
do_some_skill_up_stuff();
break_door();
return;
case DOOR_BROKEN:
break_door();
return;
case OTHER_ACTIONS:
}