Problem 1 Designing & Implementing a Proud String Class We are used to using string class that others have already desig

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Problem 1 Designing & Implementing a Proud String Class We are used to using string class that others have already desig

Post by answerhappygod »

Problem 1 Designing Implementing A Proud String Class We Are Used To Using String Class That Others Have Already Desig 1
Problem 1 Designing Implementing A Proud String Class We Are Used To Using String Class That Others Have Already Desig 1 (132.46 KiB) Viewed 14 times
please do it by using C++(QT creator),thanks
Problem 1 Designing & Implementing a Proud String Class We are used to using string class that others have already designed. In this assignment, you have a chance to design and implement a specific String class - OurString that contains the following methods using a dynamic array of characters as the underlying representation: 1. Several constructors of OurString that create one of our String objects: a) as default constructor OurString() with no arguments; b) as OurString(const char* cstr) from a constant string in C style, for example, OurString("123"); c) as OurString(string str) from a C++ string, for example: string str = "123"; OurString(str); 2. A destructor that frees any heap storage allocated by the String. 3. A toString() method that converts one of your String objects into a C++ string. 4. A method length() that returns the number of characters in the String. 5. A method substr(start, n) that returns an entirely new string that contains all the characters from the original string beginning with the index position start and continuing for n characters or through the end of the string, whichever comes first. The parameter n should be optional. If it is missing, the substring should always extend through the end of the original string. 6. A redefinition of the operator + that concatenates two String objects. 7. A redefinition of the operator << so that String objects can be written to output streams. 8. A redefinition of the operator >> so that String objects can be read from input Ahods
streams. 9. A redefinition of the bracket-selection operator that invoking str returns the character at index position i in str as an Ivalue. As an improvement over the string class in the C++ libraries, your implementation of String should call error if the string index is out of bounds. 10. A redefinition of the assignment operator and the copy constructor for the String class so that any copying operations make a deep copy that creates a new character array. = 11. A redefinition of the operator relational and comparison operators !=,>, <, >=, <= ). Relational operator Description Equal to != Not equal to Less than <= Less than or equal to Greater than or equal to >= 12. A redefinition of the operator += that performs the operation of the binary operator + on both strings and store the result into the left string. Except for the first two methods, exactly 1.c and 2, in this list, your functions should work only with the character array and several functions in C/C++ style, such as strcpy(), strcat(), strcmp() and strlen(). Note that you should make no calls to any of the methods in the C++ string class. That is why OurString is called Proud String. You should separate the interface for a class from its implementation, the class definition itself exists only in the .h file. The corresponding code appears in the .cpp file as independent method definitions that are not nested within a class definition in the way that the prototypes are. For this reason, the method definitions need to specify the class to which they belong in a different way. In C++, this identification is accomplished by adding the class name as a qualifier before the method name, separating the two with a double colon. Thus, the fully qualified name of the length method in the OurString class is OurString::length. Additionally, you need to write some code in main.cpp file to test and verify your design and implementation of OurString class. porn V AV
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply