Starting from:

$20

Assignment 3 - Phase 1 Solution

Objective

The purpose of this assignment is to gain experience with the following new concepts: C++ classes, member functions, constructors

Project Description

We know that there are some problems of using simple array representation of string, such as attempt to access locations outside of the memory allotted to the string, a string cannot easily grow without doing some dynamic allocation, etc.. In this programming assignment, you must write a String class that performs some basic operations. The class String like the following:


Your String class should have the following ADT design:

1. Modularity

The String class code must be put in its own module, i.e., a file mystring.h (the header file) should hold the class definition, and a file mystring.cpp (the implementation file) should hold the method definitions.

2. Data

Each String object should contain the following data as part of its internal representation:

· an array of characters of (sufficient) fixed length to store a string.

· a length field that will hold the current length of the string at any given moment.

3. Operations

The String class should provide the following methods for setting up, accessing and changing strings:

Note: In your implementation of String's methods, you may use the library functions provided by , which operate on the C style string (refer assignment 2).

Download Test Driver: We provide a driver (file Assign3_1driver.cpp ) that you can download and use to test your new class. You are not allowed to change it!

Upload your source code files (upload separately the two source files: your mystring.h and mystring.cpp) to this assignment.

More products