Comments

A comment is text that the compiler ignores but is useful for programmers. Comments are typically used to annotate code for reference. The compiler treats them as spaces. You can use comments during the test to make certain lines of code inactive.

Syntax

// single-line comment

/* 
  multi-line 
  documentation comment 
*/


// comment including parameters
/*
	add function
	@param x integer value to add
    @param y integer value to add
	@return addition of this two parameters
*/
int add(int x, int y) {
    return x + y;
}

Example

#include <iostream>
using namespace std;

/*
	add function
	@param x integer value to add
    @param y integer value to add
	@return addition of this two parameters
*/
int add(int x, int y) {
    return x + y;
}

int main() {
    // Variable declaration and initialization
    double x = 2, y = 4;

    cout << add(x, y); // Output

    // The backslash is a continuation character and will continue the comment to the following line \
    this is a comment too!

    /* 
    The return value is the exit code of the program, 
    the shell can read and use it. The 0 exit code means 
    that the program executed successfully 
    */
    return 0;
}
Output
6