Cpp - Introduction Comments


Consider the following code


/*A program with functions and comments */ 

#include <iostream> 
using namespace std; 

int main() // ww w  .  j a va 2 s  .  c  om
    cout << "Hello! The program starts in main()." << endl; 
    cout << "At the end of main()." << endl; 

    return 0; 


This example introduces comments.

Strings enclosed in /* . . . */ or starting with // are interpreted as comments.


/* I can cover 
    several lines */ 

// I can cover just one line 

In single-line comments the compiler ignores any characters following the // signs up to the end of the line.

Comments that cover several lines are useful when troubleshooting, as you can use them to mask complete sections of your program.