Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q1. Strings and Class Design. [35 points] The string class is provided in the C++ library. Provide your OWN implementation for the following functions in

image text in transcribed

Q1. Strings and Class Design. [35 points] The string class is provided in the C++ library. Provide your OWN implementation for the following functions in a new string class with additional features. Name your class MyString. You do not need to provide any other functions other than those listed below. The below prototypes should appear on your header file (MyString.h) and you should implement the functions in MyString.cpp MyString(char chars[], int size); //constructor void append(int n, char ch) //appends n copies of character ch at the end of the MyString object void assign(MyString s, int n); //assigns the first n number of characters of s into this MyString object, starting from the first character in this object int partCompare(MyString s, int n); //returns a value greater than 0, 0, or less than 0 if this MyString object is greater than, equal to, or less than the first n characters of s, respectively MyString commonPrefix(const MyString &s) //returns the common prefix () of this MyString object and s, if any. Returns an empty MyString otherwise. (*) Newton and Newark have the common prefix "New", ABC and abc do not have a common prefix (case sensitive), coding and cod have the common prefix "cod". Make sure to test your MyString class thoroughly, but do not include your test code in your submission

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Accidental Data Scientist

Authors: Amy Affelt

1st Edition

1573877077, 9781573877077

More Books

Students also viewed these Databases questions

Question

Explain the sources of recruitment.

Answered: 1 week ago

Question

Differentiate sin(5x+2)

Answered: 1 week ago

Question

Compute the derivative f(x)=1/ax+bx

Answered: 1 week ago

Question

What is job enlargement ?

Answered: 1 week ago

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago