Programming Exercises 521
- Explain the dangers of C’s approach to encapsulation.
- Why didn’t C++ eliminate the problems discussed in Problem 7?
- What are the advantages and disadvantages of the Objective-C approach
to syntactically distinguishing class methods from instance methods? - In what ways are the method calls in C++ more or less readable than
those of Objective-C? - What are the arguments for and against the Objective-C design that
method access cannot be restricted? - Why are destructors rarely used in Java but essential in C++?
- What are the arguments for and against the C++ policy on inlining of
methods? - Describe a situation where a C# struct is preferable to a C# class.
- Explain why naming encapsulations are important for developing large
programs. - Describe the three ways a client can reference a name from a namespace
in C++. - The namespace of the C# standard library, System, is not implicitly
available to C# programs. Do you think this is a good idea? Defend your
answer. - What are the advantages and disadvantages of the ability to change
objects in Ruby? - Compare Java’s packages with Ruby’s modules.
PROGRAMMING EXERCISES
- Design an abstract data type for a matrix with integer elements in a lan-
guage that you know, including operations for addition, subtraction, and
matrix multiplication. - Design a queue abstract data type for float elements in a language that
you know, including operations for enqueue, dequeue, and empty. The
dequeue operation removes the element and returns its value. - Modify the C++ class for the abstract stack type shown in Section 11.4.2
to use a linked list representation and test it with the same code that
appears in this chapter. - Modify the Java class for the abstract stack type shown in Section 11.4.4
to use a linked list representation and test it with the same code that
appears in this chapter. - Write an abstract data type for complex numbers, including operations
for addition, subtraction, multiplication, division, extraction of each of