MCIS-4130

Homework Assignment 8

Purpose:

This exercise will give you an opportunity to try inheritance for specialization. This is a common way of using existing components.

What to hand in:

For this assignment, please start with the supplied DUString header and body--do not use <cstring.h>.

Please hand in the dustring.h file as modified by you, and the body if modified, the CaselessDUString header and body, your test program, and your results. Also hand in answers to the questions in the Problem section of the exercise (not those in the Notes section).

Please fasten all homework papers well, and in an easily reviewable order.

Problems:

A Super String

Implement a derived type of DUString called CaselessDUString which does comparisons without regard to case. Since the original DUString class does not consider inheritance, you will need to change that class to be a better supertype by making some of its functions virtual.

Provide a reasonable test suite for your new string derived type; be sure that you include a case which compares the same character array constructing DUString and CaselessDUString and shows the comparisons differ.

(To hand in:) What should happen when you compare a DUString and a CaselessDUString? Vice-versa? Does it?

Notes:

The CaselessDUString class must provide appropriate virtual functions to allow a test program which does not differentiate between DUStrings and CaselessDUStrings except at construction time.

The CaselessDUString class will be used to hold various strings in our project model. What are the advantages of a string class over a plain old char array? The disadvantages? What other specializations of string would be nice? Why not just build one giant String class to do it all?

This is a model where we are deriving a concrete class from another concrete class. What effects does this have?

Evaluation criteria:

20

Proper changes to DUString class header and body

30

Proper CaselessDUString header file

30

Proper CaselessDUString body

20

Reasonable test file, output, and questions
Note: If your program doesn’t compile, hand in the error listing as the results!


Page 1 of 1