August 2012
Intermediate to advanced
976 pages
30h 17m
English
In C++, names have scope (§ 2.2.4, p. 48), and objects have lifetimes. It is important to understand both of these concepts.
• The scope of a name is the part of the program’s text in which that name is visible.
• The lifetime of an object is the time during the program’s execution that the object exists.
As we’ve seen, the body of a function is a statement block. As usual, the block forms a new scope in which we can define variables. Parameters and variables defined inside a function body are referred to as local variables. They are “local” to that function and hide declarations of the same name made in an outer scope.
Read now
Unlock full access