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, 21.06.2019 16:00
What tool can discover and report computer errors and conflicts that occur when you first turn on a computer and before the operating system?
Answers: 1
question
Computers and Technology, 22.06.2019 13:00
Write a program which asks you to enter a name in the form of first middle initial last. so you might enter for example samuel p. clemens. use getline to read in the string because it contains spaces. also, apparently the shift key on your keyboard doesn’t work, because you enter it all lower case. pass the string to a function which uses .find to locate the letters which need to be upper case and use toupper to convert those characters to uppercase. the revised string should then be returned to main in the form last, first mi where it will be displayed.
Answers: 1
question
Computers and Technology, 23.06.2019 08:00
Michael has written an e-mail to his employees that describes a new product special that will be introduced to the customers next week. by taking time to make sure the e-mail is well written, logical, and organized, michael has made sure his message has the characteristics of a) effective communicationb) ineffective communicationc) barriers to communicationd) workplace communication
Answers: 2
question
Computers and Technology, 23.06.2019 08:30
Based on your knowledge of a good network, describe what you think is a perfect network would be. what kind of information and resources could users share on this network. what would the network administrator do? what kind of communication would be used?
Answers: 1
You know the right answer?
Class description: A MyString class should behave much like the c++ string class. The class should u...
Questions
question
Mathematics, 12.05.2021 20:00
question
Mathematics, 12.05.2021 20:00
question
Mathematics, 12.05.2021 20:00
question
Mathematics, 12.05.2021 20:00
question
Mathematics, 12.05.2021 20:00
Questions on the website: 13722360