Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C++ program, Please include comments so i can better understand, thank you in advance! For this assignment, you will implement a version of the string
C++ program, Please include comments so i can better understand, thank you in advance!
For this assignment, you will implement a version of the string class.
Design and implement a MyString class defined by the following data: A char array reference (or pointer) for the array of characters that make up the string An integer curr_length representing the number of characters in the string (C++ only) An integer capacity that represents the size of the array Add the following methods to your class: A constructor that initializes the array to null and the curr_length to 0 A constructor that takes a String parameter and initializes the char array to the characters in the String. curr_length should be appropriately initialized. a copy constructor that takes a MyString object and initializes a new MyString object so that it is a copy of the argument string a length method that returns the number of characters in the string a private method, ensureCapacity (), that handles allocation of additional memory for the string a toString() method that returns a String representation of the Mystring object (Java), or overload the insertion operator ( operators (C++) .get(int) method that takes an integer and returns the character at that index location. PRE: the integer must be in range (Java) OR overload the index operator (C++) .toupper() and .toLower() that return a MyString that is in all upper case (or lower case) .substring(int) that takes an integer and returns the substring starting at that index. .substring(int n, int m). Return a MyString substring where n is the starting index and m is one past the ending index. .indexOf(MyString) and .lastIndexOf(MyString) that take a MyString parameter and return the starting index of the first (or last) occurrence of the MyString in the calling object. If the parameter is not found in the calling object, the method should return -1
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started