|
Table of Contents
Learning C++:
An Index of Entry Points
2. The A reference document on the basic elements of C++.
3. The Patterns
|
A common misconception at this point is that classes have only Provide and Change functions. Consider, however, a "Weight" class, with the two properties, pounds and ounces. Consider further that whoever needs this class wants to be able to add and subtract instances of this class. (We all know that adding or subtracting two English weights is not as easy as doing the same with metric weights. Figure 5.4 shows a possible CRC card for this Weight class. Note how it has more than Provide and Change functions.
We will not bother to go any further here and declare, define or use this class. Hopefully, however, you get the idea that the simple classes you have studied so far are only the tip of the iceberg as to what classes really can be used for. In other courses you will learn about classes used to create user interfaces, manage complex processes, and implement data structures such as lists of objects. If you want to get an introduction to classes as data structures, read Chapter 8 Section III.
|