< previous page page_961 next page >

Page 961
    // Empty body--nothing more to do
}
9. With static binding, the determination of which function to call for an object occurs at compile time. With dynamic binding, the determination of which function to call for an object occurs at run time. 10. Identify the objects and operations, determine the relationships among the objects, and design the driver. 11. Use a built-in data type, use an existing ADT, or create a new ADT.
Exam Preparation Exercises
1. Define the following terms:
structured design
method (of an object)
code reuse
is-a relationship
state(of an object)
has-a relationship
instance variable (of an object)

2. In C++, inheritance allows a derived class to access directly all of the functions and data of its base class. (True or False?)
3. Given an existing class declaration
class Sigma
{
public:
    void Write() const;
      .
      .
      .
private:
    int n;
};
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
a programmer derives a new class Epsilon as follows:
class Epsilon : Sigma
{
public:
    void Twist();
    Epsilon( /* in */ float initVal );
private:
    float x;
};
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Then the following client code results in a compile-time error:
Epsilon someObject(4.8);

someObject.Write();    // Error
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
a. Why is the call to the Write function erroneous?
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
b. How would you fix the problem?
4. Consider the following two class declarations:

 
< previous page page_961 next page >