subject

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

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 01:00
Duplicating objects creates copies that a. move differently than the original object b. erase the original object c. look and act like the original object d. add events to a game
Answers: 1
question
Computers and Technology, 22.06.2019 20:00
How is the number 372 written when expanded out to place values in the base 8 (octal) number system? a. 2 x 4 + 3 x 2 + 4 x 1 b. 3 x 64 + 7 x 8 + 2 x 1 c. 3 x 8 + 7 x 7 + 2 x 6 d. 3 x 100 + 7 x 10 + 2 x 1
Answers: 1
question
Computers and Technology, 22.06.2019 22:30
Who needs to approve a change before it is initiated? (select two.) -change board -client or end user -ceo -personnel manager -project manager
Answers: 1
question
Computers and Technology, 23.06.2019 01:20
Me with this program in c++ ! computers represent color by combining sub-colors red, green, and blue (rgb). each sub-color's value can range from 0 to 255. thus (255, 0, 0) is bright red. (130, 0, 130) is a medium purple. (0, 0, 0) is black, (255, 255, 255) is white, and (40, 40, 40) is a dark gray. (130, 50, 130) is a faded purple, due to the (50, 50, 50) gray part. (in other word, equal amounts of red, green, blue yield gray).given values for red, green, and blue, remove the gray part. ex: if the input is 130 50 130, the output is: 80 0 80. thus, find the smallest value, and then subtract it from all three values, thus removing the gray.
Answers: 3
You know the right answer?
Class description: A MyString class should behave much like the c++ string class. The class should u...
Questions
Questions on the website: 13722361