Logo Data Structures and Algorithms with Object-Oriented Design Patterns in C++
next up previous contents index

Projects

  1.   Design and implement suitable Compare functions for the C++ built-in types int, char, double and string so that they may be wrapped using the Wrapper<T> class declared in Program gif.
  2. Using visitors, devise implementations for the IsMember and Find member functions of the SearchableContainer class declared in Program gif.
  3. Using iterators, devise implementations for the IsMember and Find member functions of the SearchableContainer class declared in Program gif.
  4. Devise a scheme using visitors whereby all of the objects contained in one searchable container can be removed from it and transfered to another container.
  5.   A bag  is a simple container that can hold a collection of objects. Design and implement a concrete class called Bag derived from the SearchableContainer class declared in Program gif. Use the Array<T> class given in Chapter gif to keep track of the contents of the bag.
  6. Repeat Project gif, this time using the LinkedList<T> class given in Chapter gif.
  7. Ownership is all or nothing--a container owns all the object it contains or none of them. However, sometimes it is useful for an association to be the owner of the key but not of the associated value. Design and implement a class called Assoc which has this characteristic. Derive the class Assoc from the class Association given in Program gif.
  8. The Java  programming language provides the notion of an enumeration  as the means to iterate through the objects in a container. In C++ we can define enumerations like this:
    class Enumeration
    {
    public:
        virtual bool hasMoreElements () const = 0;
        virtual Object& nextElement () = 0;
    };
    Given an enumeration e for some container c, the contents of c can be printed like this:
    while (e.hasMoreElements ())
        cout << e.nextElement () << endl;
    Devise a wrapper class to encapsulate an iterator and provide the functionality of an enumeration.


next up previous contents index

Bruno Copyright © 1997 by Bruno R. Preiss, P.Eng. All rights reserved.