Comments in C++

C++ Tutorial

While you are writing any source code, you must pay attention the readability and attractiveness of it.

Because, this code should be understandable for any other programmer/developer. If it has several classes and algorithms, it requires some definitions. In this case, we need the comments.

Comments are the explanatory statements. C++ supports both of single and multi-line comments.

#include <iostream>
using namespace std;

int main() {
   cout << "Hello Procademy"; // prints Hello Procademy

   // it is single line comment

  /* It is 
          multiline comment */

   return 0;
}

You can write any character into the comment. C++ compilers ignore them while the execution. In other words, comment do not affect the program.

As the code above, double slash (//) is the beginning of single line comment and any character written after it is considered comment’s element.

Multiline comment starts with /* characters and ends with */ characters.

Leave a Reply

Your email address will not be published. Required fields are marked *