Sample Assignment: The String Class
(Chapter 4)

Data Structures and Other Objects Using C++
Third Edition
by Michael Main and Walter Savitch
ISBN 0-321-19716-X

The Assignment:
Implement and test the string class from Section 4.5. The class should be implemented by yourself (though you may talk with other students). An non-interactive test program is provided for you at This test program does not completely test your work (for example, it does not test the getline function).
Ensure that you can write a class that uses dynamic memory.
Before Starting:
Read Sections 4.1 through 4.5
Files that you must write:
  1. mystring.h: The header file for the string class. You may start with the book's version of this file.
  2. string.cxx: The implementation file for the new string class. You will write all of this file, which will have the implementations of all the string's member functions.
  3. You want to write additional tests beyond stringexam.cxx.

Michael Main (