+ 2
Why use a multi-line comment when you can just use a single-line comment if neither one actually shows up in a code? Any examples of each use?
//single-line comment vs. /*multi-line comment*/
4 Antworten
+ 4
// fix later
/* I should probably fix this later at some point in the future, some of these things i need to fix are;
collision
collecting credentials
optimizations on the boot loader
*/
+ 2
Comments are ignored by the compiler, but it doesn't mean they are useless. Use them to add notes to your codes: explanations of how a function work or what a variable is used for, ideas for improvement, TODOs, temporary removal of code, etc. They can be a great source of info for the ones reviewing your code (including you).
Use the multiline one when you want to put a big block of comment. That way, you don't have to put // at the beginning of each line.
+ 2
Besides commenting...
I often use /* */ to tell the compiler to ignore entire blocks of code that I refuse to delete or keep as back-up, within a text file, in case I accidentally wreck a code block I am working on.
/* */ is also good for troubleshooting purposes because it can be used to quickly hide multiple lines or blocks of code from the compiler to help isolate and locate faulty code within your program.
There are compilers that can do this for you with a simple click, I use Visual Studio, but I prefer practicing with old school methods because I am a purist.
0
Thank you all for the help. I have a much better understanding now