Cpp - Introduction Comments

Introduction

Consider the following code

Demo

/*A program with functions and comments */ 

#include <iostream> 
using namespace std; 

int main() /* w w w  .j  ava 2 s.  c o  m*/
{ 
    cout << "Hello! The program starts in main()." << endl; 
    cout << "At the end of main()." << endl; 

    return 0; 
}

Result

This example introduces comments.

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

Examples:

/* 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.