|
|
 |
|
|
|
|
If there is no constructor initializer, the member object's default constructor is invoked. |
|
|
|
|
|
|
|
|
7. To obtain dynamic binding of an operation to an object when passing class objects as parameters, you must |
|
|
|
 |
|
|
|
|
pass the object using pass-by-reference. |
|
|
|
 |
|
|
|
|
declare the operation to be virtual in the class declaration. |
|
|
|
|
|
|
|
|
8. If a base class declares a virtual function, it must implement that function even if the body is empty. |
|
|
|
|
|
|
|
|
9. A derived class cannot redefine the function return type of a virtual function. |
|
|
|
|
|
|
|
|
Object-oriented design (OOD) decomposes a problem into objectsselfcontained entities in which data and operations are bound together. In OOD, data is treated as an active, rather than passive, quantity. Each object is responsible for one part of the solution, and the objects communicate by invoking one another's operations. |
|
|
|
|
|
|
|
|
OOD begins by identifying potential objects and their operations. Examining objects in the problem domain is a good way to begin the process. The next step is to determine the relationships among the objects using inheritance (to express is-a relationships) and composition (to express has-a relationships). Finally, a driver algorithm is designed to coordinate the overall flow of control. |
|
|
|
|
|
|
|
|
Object-oriented programming (OOP) is the process of implementing an object-oriented design by using language mechanisms for data abstraction, inheritance, and dynamic binding. Inheritance allows any programmer to take an existing class (the base class) and create a new class (the derived class) that inherits the data and operations of the base class. The derived class then specializes the base class by adding new private data, adding new operations, or overriding inherited operationsall without analyzing and modifying the implementation of the base class in any way. Dynamic binding of operations to objects allows objects of many different derived types to respond to a single function name, each in its own way. Together, inheritance and dynamic binding have been shown to reduce dramatically the time and effort required to customize existing ADTs. The result is truly reusable software components whose applications and lifetimes extend beyond those conceived of by the original creator. |
|
|
|
|
|