Comments in compiler
Comment is part of the source codes disregarded by the compiler. They simply do nothing. Their purpose is only to allows the programmer to insert notes or description embedded within the source codes.
C++ supports two ways to inserts comments:
// line comment
/* block comment */
The first of them, known as line comments, discard everything from where the pair of slash signs (//) is found up to the ends of that same lines. The second one, known as block comment, discard everything between the /*
character and the first appearance of the */ characters, with the possibility of including more than one lines.
We are going to add comment to our second program:/* my second program in C++
with more comments */
using namespace std;
int main ()
cout << "My comment in C++! "; // prints My comment in C++!
cout << "I'm a C++ programer"; // prints I'm a
My comment in C++! I'm a C++ programer
If you include comment within the source code of your programs without using the comment characters