Comp 345
Assignment 3
Topic: Strings Part 1
Points: 25

Goals

  1. Review use of pointers
  2. Review dynamic memory
  3. Make good use of encapsulation and information hiding

Instructions

  1. Start with these files:
    string.h
    string.cpp

  2. Implement the functions that are commented out in the header file.
  3. Be sure to check for NULL pointers in every possible scenario.
  4. Make sure your test program thoroughly tests your string class.

Details

When writing your insert functions:
When the index to insert into the string is < 0 use the prepend functionality of your class.
When the index to insert into the string is > the length of pString use the append functionality of your class.


Hints

You should only have to implement the logic of your functions in one place per function type. For example you should only have to write the append functionality once. Use that function from all of your other functions. I recommend placing your logic in the functions that take the char*. It is ease to create one of those and call it from the others.

 

Files to Submit

 

string.h

string.cpp

test.cpp