Skip to main content

1.11) Documenting Your Code: Comments


The compiler ignores anything from // to the end of the current line; text appearing after // is for the benefit of people reading your code (see the example below).

C++ also supports the C style of comments, in which the compiler ignores anything appearing between /* and */.

// The classic "Hello World!" program in C++
#include <iostream>
using namespace std;
int main()
{
  cout << "Hello World!" << endl;
  return 0;
}