Our String class always deletes the old character buffer and allocates a new character buffer on assignment or in the copy constructor.

computer science

Description

Problem 1 Modify the String class in the following ways: 


a) Our String class always deletes the old character buffer and allocates a new character buffer on assignment or in the copy constructor. This need not be done if the new value is shorter than the current value and hence would fit the existing buffer. Rewrite the String class to only allocate a new buffer when necessary. Abstract the common tasks from the assignment operator and the copy constructor and place them in an internal (private) method. 


b) Overload the compound += operator to perform concatenation of two String objects. 


c) Overload the + operator using the += operator. 


d) Add a member function compare (String) that returns -1 or 0 or 1 dep


Related Questions in computer science category


Disclaimer
The ready solutions purchased from Library are already used solutions. Please do not submit them directly as it may lead to plagiarism. Once paid, the solution file download link will be sent to your provided email. Please either use them for learning purpose or re-write them in your own language. In case if you haven't get the email, do let us know via chat support.