-
Data Members, ‘set’ Functions, & ‘get’ Functions–C++ Notes (C Plus Plus Notes)
Variables declared in a functions body are local variables, and can be used only from the point of their declaration in the function to the immediately following closing right brace (}). When a function terminates, the values of its local variables are lost. 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. Data members normally are private. Variables or functions declared private are accessible only to member functions of the class in which they’re declared, or to friends of the class. When a program creates (instantiates) an object of a class, its…