Exploring the C++ program structure
In C++, programs execute code line by line, with each statement typically terminated by a semicolon. A collection of code lines that perform specific tasks can be grouped as a function, enclosed by a pair of curly braces, with the function having a name followed by a set of parentheses.
For example, the main.cpp
file we created in Chapter 2 has two statement lines of code – the two lines of code are enclosed within a pair of curly braces, and the grouped block of code’s function name is main
(see Figure 3.2).
Figure 3.2 – The main.cpp code sample
C++ source programs generally follow the same program structure:
#include
statements at the beginning of the program, which allow this program to access the C++ system library and other C++ source program functionalities.#include
statements are special statements that don’t end with a semicolon.
Note
The C++ system library is...