Question: See also client program and correct output. MyString object will have the ability to make a full deep - copy of itself when copied of
See also client program and correct output.
MyString object will have the ability to make a full deepcopy of itself when copied of the assignment, but full documentation will be required for the next part. Here is a list of the operations this class must support:
A length member function that returns the number of characters in the string. Use strlenbasis. Use strcpy Printing a MyString to a stream using an overloaded insertion operator, which should simply print out its characters. Use of the comparison operator. You must do this using only one function for each of the six operators. Don't forget to include the big may NOT use anything from the C string class!!
file: #pragma warningdisable:csmystring". Client program These functions are designed to help you test your MyString objects, as well as show the client usage of the class. The BasicTest function builds an array of strings using various constructor options and prints them out. It also uses the String stream operations to read some strings from a data file. The RelationTest function checks out the basic relational operations etc on Strings and char s The CopyTest tries out the copy constructor and assignment operators to make sure they do a true deep copy. Although not exhaustive, these tests will help you to exercise the basic functionality of the class and show you how a client might use it While you are developing your MyString class, you might find it easier to comment out functions you are ready for, so that you don't get lots of compilelink complaints. #include "mystring.h #include for toupper #include #include using namespace std; using namespace csmystring; void BasicTest; void RelationTest; void CopyTest; MyString AppendTestconst MyString& ref, MyString val; string boolStringbool convertMe; int main BasicTest; RelationTest; CopyTest; void BasicTest MyString s; cout Testing basic String creation & printing" endl; const MyString strsMyStringWow MyStringC is neat!" MyString MyStringaz; for int i ; i ; i cout "string i strsi endl; cout endl Testing access to characters using const endl; const MyString sabcdefghijklmnopqsrtuvwxyz; cout "Whole string is s endl; cout "now char by char: ; for int i ; i slength; i cout si; cout endl Testing access to characters using nonconst endl; MyString sabcdefghijklmnopqsrtuvwxyz; cout "Start with s; for int i ; i slength; i si touppersi; cout and convert to s endl; string boolStringbool convertMe if convertMe return "true"; else return "false"; void RelationTest cout
Testing relational operators between MyStrings
; const MyString strsMyStringapp MyStringapple MyString MyStringBanana MyStringBanana; for int i ; i ; i cout "Comparing strsi to strsi endl; cout Is left right? boolStringstrsi strsi endl; cout Is left right? boolStringstrsi strsi endl; cout Is left right? boolStringstrsi strsi endl; cout Is left right? boolStringstrsi strsi endl; cout Does left right? boolStringstrsi strsi endl; cout Does left right boolStringstrsi strsi endl; cout
Testing relations between MyStrings and char
; MyString she; const char t "hello"; cout "Comparing s to t endl; cout Is left right? boolStrings t endl; cout Is left right? boolStrings t endl; cout Is left right? boolStrings t endl; cout Is left right? boolStrings t endl; cout Does left right? boolStrings t endl; cout Does left right boolStrings t endl; MyString uwackity; const char v "why"; cout "Comparing v to u endl; cout Is left right? boolStringv u
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
