Notice after the statement
max(0, 0) = 99;
was executed the value of nLimit changed to 99. Only your creativity limits how you use this ability of C++.
Classes
Classes are one of the most important elements of C++. They enable you to use one of the most powerful features of the language—data object management. You might think of classes as an extension to C’s user-defined types. In C, when defining a type (using typedef), you can include only actual data objects in that type. No checking takes place to find if correct values have been assigned to a C user-defined type.
Using C++ classes gives you many advantages. These advantages, described in the following section, are valuable in maintaining your application’s data integrity.
A class can have all the allowed data types within it, including other classes. Nesting classes is done much the same as you would nest typedef’d objects in C.
A class has a constructor, a function called whenever a data object of that class is created. You may have more than one constructor, each of which must have a different number of parameters. The constructor is responsible for ensuring that each member of the class is properly initialized and that any initialization values passed to the constructor are valid.
A class has a number of manipulation functions that you can use to store values in the class’s members, retrieve member values, print, output, input, or otherwise manipulate its members.
A class also has a destructor, a function called whenever the class object is about to be destroyed. This function can take care of housekeeping, such as freeing any allocated memory.
Using a class requires you to determine, as well as you possibly can, what you will use for members in the class. You never have a problem adding members as needed or writing class functions to access new members; however, planning ahead helps prevent unchecked changes that can cause problems.