Difference between // comments, /* */ comments and /// comments.What are Comments?
- Comments are the portions of the code which is ignored by the compiler.
- It allows the user to make simple notes in the relevant areas of the source code.
- It is used for formal documentation for understanding particular code and its operation.
- It can be used to explain source code and to make it more readable.Types of Comments:
1. Single-line comment (// )
2. Multi-line comment (/* */)
3. XML Documentation comment (///)1. Single-line comment (// ):
- It can start with ' // '
- It is a single line comment.Example:
cout<<"Hello world"; //'cout' is used for printing the output, it prints Hello world
- In the above example, with the // comment, describing the use of 'cout' statement.2. Multi-line comment (/* */):
- It can start with /* and end with */.
- You can add multiple comments.
- Using this, you can nested one comment within the other comment.Example:
cout<<"How are you?";
- In the above example, you can add multiple comments using multi-line comments.3. XML Documentation comment (///):
- It is used for XML documentation.
- It provides information about code elements such as functions, fields and variables.Example:
/// Example 1
/// Using <summary> rag