#include // I/O library
using namespace std;
int main()
{
cout << “Hello, world!” << endl;
}

The // symbol is used as a rest-of-line comment symbol. Also, the program text can be placed in any position on the page, with white space between tokens being ignored. White space are characters such as blanks, tabs, and new lines. White space, comments, and indentation of text are all used to create a well-documented, readable program but do not affect program semantics.

#include <iostream> // I/O library

The C++ program is compiled after the preprocessor executes #-designated directives. The preprocessor precedes the compiler translation of the resulting program into machine code. The #include directive found in the example program hello.cpp imports any needed files, usually library definitions. In this case, the I/O library for a typical C++ compiler system is found in the file iostream. The compiler knows where to find this and other system files.

Using namespace std;

On C++ systems, standard C++ I/O header files are wrapped in namespace std. The using declaration allows names to be used without std:: prepended to each name. The include files could have been coded without namespace and using, as follows:

#include <iostream.h> // I/O library

Most systems provide older style library_name.h header files. These libraries do not require the using namespace std; statement.

Did find the post very useful? Maybe you want to buy me a glass of beer!