-
goto statements
one of my friends was saying goto statements arent used much in c++ very much, if that is true then alright but if not i would like to know how to use them... cause i cant get my game to go back to the start if someone dies or if they kill something. can someone please help me?
-
Some people on this board will tell you to never use goto statements. They say if you need to use them you have bad design. In my opinion there are very rare circumstances where you may have to use them for maximum efficiency. I think also you would use them in say BIOS programming or something. In your case, however, I do not think go to statements would be beneficial. You should perhaps call your appropriate functions and wrap them in a simple loop. Check out the basics of a while loop and I think that should probably help you out. Any questions? Just ask.
-
I agree with Wiz there. I think this is almost a universal truth. There are instances when even the most shaddy aspects of a programming language may be useful.
As an example I was reading the other day some anti-cracking techniques to use when designing your own serial number software protection schemes... they actually advise you to use goto and use it often as it will make crackers go nuts on their dissasemblers
If you have a good reason to use it, you go ahead and don't mind the purists. You just have to make sure you really need it and the consequences of using it. But if you are learning the language, be especially careful. It's best to go the hard route than to fall prey of the vices these commands offer.
Bad practice is not an adjective to qualify a language feature. It's an adjective to qualify a programmer.
-
Re: goto statements
The goto statement has been discussed quite a bit in the last couple of days.