< previous page page_897 next page >

Page 897
Exam Preparation Exercises
1. The specification of an abstract data type (ADT) should not mention implementation details. (True or False?)
2. Below are some real-world objects you might want to represent in a program as ADTs. For each, give some abstract operations that might be appropriate. (Ignore the concrete data representation for each object.)
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
a. A thesaurus
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
b. An automatic dishwasher
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
c. A radio-controlled model airplane
3. Consider the following C++ class declaration and client code:
Class declaration
Client code
class SomeClass
SomeClass object1;
{
SomeClass object2;
public:
int       m;
void Func1( int n );
int Func2( int n ) const;
object1.Func1(3);
void Func3();
m = object2.Func2(5);
private:
int someInt;
};

3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
a. List all the identifiers that refer to data types (both built-in and programmer-defined).
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
b. List all the identifiers that are names of class members.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
c. List all the identifiers that are names of class objects.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
d. List the names of all member functions that are allowed to inspect the private data.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
e. List the names of all member functions that are allowed to modify the private data.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
f. In the implementation of SomeClass, which one of the following would be the correct function definition for Func3?
i.  void Func3()
    {
        .
        .
        .
    }
ii. void SomeClass::Func3()
    {
        .
        .
        .
    }
iii.SomeClass::void Func3()
    {
        .
        .
        .
    }

 
< previous page page_897 next page >