Question: In C++, implement a string class using a dynamically allocated array. The array of char should be null terminating. You must implement the following methods
In C++, implement a string class using a dynamically allocated array. The array of char should be null terminating. You must implement the following methods:
Default constructor (allocates 128 characters as capacity)
Constructor that takes an integer value as the capacity to allocate
Copy constructor
Destructor
Reallocate that changes the capacity of a string (larger or smaller) and preserves as much of the contents of the string as possible.
Assignment overload the operator= with standard C++ semantics.
Constant time swap swaps two strings in constant time regardless of their capacity
Length
Capacity
You can NOT use STL or any other predefined library, built in types (such as std::string), or C functions (such as strcpy).
Previous
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
