【正文】
ccessed by the member functions of a class as well as by member functions of derived classes. However, like private members, protected members cannot be accessed by user programs. One final note about objects. Recall that message passing is the fundamental means for munication among objects. When we write i () we are effectively sending a message to the a2 array object to determine the size of the array and return it. In actuality, no message is really sent. C++ emulates message passing through the use of function calls. The piler ensures us that the correct function will be called for the desired object. So, in C++ you can think of message passing as function calls. Objectorientation has bee a buzzword with many meanings. It is a design methodology, a paradigm (a way of thinking about problems and finding solutions), and a form of programming. As a design methodology, we can use objectoriented techniques to design software systems. But it is more than a design methodology, it is a whole new way of thinking about problems. Objectoriented design allows us to think about the actual realworld entities of the problem we are attempting to provide a solution for. Beginning the design with concepts from the real world problem domain allows the same concepts to be carried over to implementation, making the design and implementation cycle more seamless. Once a design has been conceived, a programming language can be chosen for implementation. By factoring out the inheritance relationships from the object hierarchies discovered during design, one can even implement the system in a traditional, non objectoriented language. However, using an objectoriented language, such as C++, makes it easier to realize the design into an implementation because the inherent relationships among objects can be directly supported in the language. Languages such as C++ are considered hybrid languages because they are multiparadigm languages. C++ is an object oriented extension of C and can be used as a procedural language or as an objectoriented language. In this issue, we continue our tour of the objectoriented features of C++. The ObjectOriented Features of C++ INHERITANCE in C++. One of the major strengths of any objectoriented programming language is the ability to build other classes from existing classes, thereby reusing code. Inheritance allows existing types to be extended to an associated collection of subtypes. 11 Recall that one of the key actions of objectoriented design is to identify realworld entities and the relationships among them. When a software system is designed, a variety of objects arise, which may be related in one way or another. Some classes may not be related at all. Many times it makes sense to anize the object classes into an inheritance hierarchy. Organizing a set of classes into a class hierarchy requires that we understand the relationships among the classes in detail. Not all class relationships dictate that inheritance be used. C++ provides three forms of inheritance: public, private, and protected. These different forms are used for different relation ships between objects. To illustrate these different types of inheritance, let39。s structure. The model helps us think about and formulate solutions. We can use the mental model of a paradigm independently from the programming language chosen for implementation. However, when the chosen language provides constructs and mechanisms that are similar to those that are found in the paradigm, the 7 implementation will be more straightforward. Usually, there are several languages that belong to a paradigm. For this reason, a programming paradigm is also considered a class of languages. A language does not have to fit into just one paradigm. More often, languages provide features or characteristics from several paradigms. Hybrid languages, such as C++, bine characteristics from two or more paradigms. C++ includes characteristics from the imperative and procedural paradigms just like its predecessor language, C and the objectoriented paradigm. THE IMPERATIVE PARADIGM. The imperative paradigm is characterized by an abstract model of a puter with a large memory store. This is the classic von Neumann model of puter architecture. Computations, which consist of a sequence of mands, are stored as encoding within the store. Commands enable the machine to find solutions using assignment to modify the store, variables to read the store, arithmetic and logic to evaluate expressions, and conditional branching to control the flow of execution. THE PROCEDURAL PARADIGM. The procedural paradigm includes the imperative paradigm, but extends it with an abstraction mechanism for generalizing mands and expressions into procedures. Parameters, which are essentially aliases for a portion of the store, were also introduced by this paradigm. Other features include iteration, recursion, and selection. Most mainstreams programming today is done in a procedural language. The procedural paradigm was the first paradigm to introduce the notion of abstraction into program design. The purpose of abstraction in programming is to separate behavior from implementation. Procedures are a form of abstraction. The procedure performs some task or function. Other parts of the program call the procedure, knowing that it will perform the task correctly and efficiently, but without knowing