O'Reilly logo

Sams Teach Yourself C++ in 24 Hours, Third Edition by Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Parts of a Simple Program

The simple program from the first hour, HELLO.CPP, had many interesting parts. This section will review this program in more detail. Listing 2.1 reproduces the original version of HELLO.CPP for your convenience.

Listing 2.1. HELLO.CPP Demonstrates the Parts of a C++ Program
0:  #include <iostream>
1:
2:  int main()
3:  {
4:      std::cout << "Hello World!\n";
5:      return 0;
6:  }
Hello World!

On line 0 the file iostream is included in the file. As far as the compiler is concerned, it is as if you typed the entire contents of the file iostream right into the top of HELLO.CPP.

Examining the #include, Character by Character ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required