... identifiers that begin with underscores and double underscores, because C++ compilers use names like that for their own purposes internally.
Placement of Variable Declarations
Declarations of variables can be placed almost anywhere in a program, but they must appear before their corresponding variables are used in the program. For example, in the program of Fig. 2.5, the declaration in line 8
int number1{0}; // first integer to add (initialized to 0)
could have been placed immediately before line 13
std::cin >> number1; // read first integer from user into number1
the declaration in line 9
int number2{0}; // second integer to add (initialized to 0)
could have been placed immediately before line 16
std::cin >> number2; // read second integer ...
Get C++ How to Program, 10/e now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.