3.4. Data Members, set Member Functions and get Member Functions
In Chapter 2, we declared all of a program’s variables in its
main function. Variables declared in a function definition’s body are known as local variables and can be used only from the line of their declaration in the function to the closing right brace (
}) of the block in which they’re declared. A local variable must be declared before it can be used in a function. A local variable cannot be accessed outside the function in which it’s declared. When a function terminates, the values of its local variables are lost. (You’ll see an exception to this in Chapter 6 when we discuss
static local variables.)
A class normally consists of one or more member functions that manipulate the ...