Question: What's the missing code? and where to put it? Requirements: Implement the following string methods O . DynamicString() //Constructs an empty string. Allocating enough memory

 What's the missing code? and where to put it? Requirements: Implementthe following string methods O . DynamicString() //Constructs an empty string. Allocatingenough memory to store the null character DynamicString(const char* str) //Constructs a

What's the missing code? and where to put it?

Requirements: Implement the following string methods O . DynamicString() //Constructs an empty string. Allocating enough memory to store the null character DynamicString(const char* str) //Constructs a string by copying the characters from the char array str to this object. You should dynamically allocate enough memory for the entire string. int len() const //returns the length of this string (i.e. the number of characters in the array not including the null char) const char* c_str() const // returns a pointer to the underlying char array char char_at(int position) const // returns the char at the specified position char& operator[](int position) // returns the char at the specified position bool startsWith(const DynamicString& other) const //True if other is a prefix of this string bool endsWith(const DynamicString& other) const //True if other is a suffix of this string int compare(const Dynamic String& other) const // negative if this is smaller than other, o if this is equal to other, positive if this is larger than other int iCompare(const DynamicString& other) const // same as compare but is case-insensetive Dynamic String& tolower() // converts the string to lowercase Dynamic String& toUpper() // converts the string to uppercase Dynamic String& replace(char old, char new) //replace all instances of old with new int find(char needle, int start=0) const //return the first index of the specified char or -1 if the char is not found starting from index start. int reverseFind(char needle, int start) const //return the right-most index (less than or equal to start) of the specified char or -1 if the char is not found. . O . DynamicString.cpp* + x ynamicString Test.cpp Challenge 1 (C #include "Dynamicstring.h" #include #include 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 using std::out_of_range; using std::tolower; using std::toupper; using std::ostream; LDynamicString::Dynamicstring(){ [] DynamicString: :Dynamicstring(const char* str){ gint Dynamicstring: :len() const{ return -1; 20 21 22 Econst char* DynamicString::c_str() const{ B /*Delete this garbage and just return cstr * once you have your constructors implemented 24 char* garbage = new char[1]; garbage[@] = '\0'; return garbage; 27 28 n Echar DynamicString::char_at(int position) const{ return 'z'; Echar& Dynamicstring::operator[](int position) { 30 31 32 33 34 35 36 37 38 39 42 41 42 return *(new char('z')); gbool DynamicString::startsWith(const Dynamicstring& other) const{ return true; DynamicString.cpp* + x ynamicString Test.cpp Challenge 1 return true; gbool DynamicString::endsWith(const DynamicString& other) const{ return true; Fint DynamicString::compare(const DynamicString& other) const { return -1; Eint Dynamicstring:: iCompare(const Dynamicstring& other) const{ return -1; DynamicString& Dynamicstring: :tolower() { return *this; EDynamicString& Dynamicstring::toupper({ return *this; 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 EDynamicString& Dynamicstring: :replace(char old, char newch) { return *this; gint Dynamicstring::find(char c, int start) const{ return -1; Eint Dynamicstring: :reverseFind(char c, int start) const! return -1; gint DynamicString: :reverseFind(char c) const{ return -1; Fostream& operator

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!