Computers and Technology

Class description: A MyString class should behave much like the c++ string class. The class should use a dynamically allocated char array to hold a character string. If the amount of memory allocated to the array is too small to complete some necessary task (e. g., assigning a new character string to the object) the object should automatically double its capacity until it is large enough to complete the task. If it's discovered that the object is using less than 25% of its capacity the object should shrink to half its capacity until it is using more that 25% of its capacity. Assignment: Implement the MyString class using a header and implementation file named MyString. h and MyString. cpp respectively. Even though MyString. h will be provided on the upload site, create own version for testing code locally. Make sure to properly test code on by creating a test driver that fully tests every function created in the MyString class
Memory Requirements: MyString should start with 10 bytes of allocated memory and should grow in size by doubling. So, we should be able to predict the capacity of MyString as acquiring a patten of 10, 20, 40, 80, … bytes of memory depending of the number of characters stored.
Attributes:
int size – the number of characters currently stored in the string object. Do NOT count the NULL character.
int capacity – the number of bytes currently allocated. This should always be at least size + 1. The extra byte is needed to store the NULL character.
char *data – character pointer that points to an array of characters.
Member Functions:
MyString( ) Constructor
MyString(const char *) Constructor with an initialization character string
~MyString( ) Destructor
MyString(const MyString &) Copy constructor
MyString& operator = (const MyString&) Overloaded assignment operator, make a copy of MyString object
bool operator == (const MyString&) const overloaded equivalence relational operator
char& operator [ ] (int) overloaded [ ] should return a char by reference
void operator += (const MyString&) overloaded += operator, use to concatenate two MyStrings
MyString operator + (const MyString&) const Create a new MyString object that is the concatenation of two MyString objects
void getline(istream&, char delimit = ‘\n’); reads an entire line from a istream. Lines are terminated with delimit which is newline ‘\n’ by default
int length( ) const; return the length of the string
friend ostream& operator<< (ostream&, MyString&); overloaded insertion operator

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 18:30, Jessieeeeey
Kto rozmawia z clamentain przez krótkofalówke w the walking dead która śledzi lee w 4 epizodzie
Answers: 1
image
Computers and Technology, 23.06.2019 18:00, teamroper35
Which finger presses the h key on the keyboard? index finger on the left hand pinky finger on the right hand index finger on the right hand thumb on the left hand
Answers: 1
image
Computers and Technology, 23.06.2019 18:40, brooklyn4932
How does is make you feel when you're kind to others? what are some opportunities in your life to be more kind to your friends and loved ones? imagine a world where kindness has be outlawed. how would people act differently? would your day-to-day life change significantly? why or why not?
Answers: 2
image
Computers and Technology, 24.06.2019 10:00, noahmace
When writing a business letter, how many times can you use the same merge field in a document? once once, unless using the address block feature unlimited it will depend on the type of document you choose
Answers: 1
Do you know the correct answer?
Class description: A MyString class should behave much like the c++ string class. The class should u...

Questions in other subjects:

Konu
Mathematics, 11.09.2020 21:01
Konu
Mathematics, 11.09.2020 21:01
Konu
Mathematics, 11.09.2020 21:01
Konu
Mathematics, 11.09.2020 21:01
Konu
Mathematics, 11.09.2020 21:01
Konu
Mathematics, 11.09.2020 21:01
Konu
English, 11.09.2020 21:01
Konu
Mathematics, 11.09.2020 21:01
Konu
Mathematics, 11.09.2020 21:01
Konu
Social Studies, 11.09.2020 21:01