How to write comments in C++
In this tutorial, we are going to learn about how to write the comments in C++.
Comments helps us to understand the code in future, in case if we forgot what is happening on the particular line of code.
There are two ways to write comments in C++.
Single line comment
To we can write a single line comment in C++, we can use the forward slashes //
followed by the comment.
Here is an example:
// this is a single-line comment
Anything we written after //
is ignored by the compiler.
Multiline comments
To write a multiline comment, we can use C++ /*
and */
syntax.
Here is an example:
/*
you can
see mee
in multiple lines
*/
The multiline comment starts after the /*
and ends at */
.