Type of Comments
In cpp programming language we have two type of comments.
1. Single Line Comment
2. Multi Line Comment
Single Line Comment:
Single line comments are used to hide single line of code or text from compiler.
Single-line comments start with two forward slashes (//).
Any text after // will be ignored by the cpp compiler
Syntex:
// This is a single line comment
printf("Hello World!");
printf("Any Message!"); // This is a single line comment
Multi Line Comment:
Multi-line comments are used to hide group or block of text from compiler.
Multi-line comments start with /* and ends with */ in cpp language.
Any text between /* and */ will be ignored by the cpp compiler
Syntex:
/* here we have a code written below will print the Message
to the screen, and this is amazing use of multiline comment */
printf("Message!");
should i use single line comment or multiline comment?
It's up to developer which one he wants to use. Normally, we use // for short comments, and /* */ for longer one.
Few things that must remember while writing comments in cpp programing: