Texas A&M University _ CSCE 121 Introduction to Program Design and Concepts MyString.cpp.
Texas A&M University _ CSCE 121 Introduction to Program Design and Concepts MyS. Implement this source file #include "MyString.h" #include iostream using std::ostream, std::iostream; My String::MyString(): capacityPriv(1), sizePriv(0), cString(new char[1]{'0'}){} MyString::MyString(const char* object): capacityPriv(1), sizePriv(0), cString(new char[1]{'0'}){ size_t n = 0; while( object[n]){ n++; } resize(n); delete[] cString; cString = new char[n+1]; for (size_t i = 0; i = n; ++i){ cString[i] = object[i]; } //delete[] object; } MyString::MyString(MyString& other): capacityPriv(1), sizePriv(0), cString(new char[1]{'0'}) { delete[] cString; cString = new char[ity()]; sizePriv = h(); capacityPriv = ity(); for (size_t i = 0; i = h(); ++i){ cString[i] = other.cString[i]; }MyString& MyString::operator=(MyString& other){ if (this != &other){ delete[] cString; cString = new char[ity()]; sizePriv = h(); capacityPriv = ity(); for (size_t i = 0; i = h(); ++i){ cString[i] = other.cString[i]; }
Written for
- Institution
- Texas A&M University _ CSCE 121 Introduction to Pr
- Course
- Texas A&M University _ CSCE 121 Introduction to Pr
Document information
- Uploaded on
- April 28, 2023
- Number of pages
- 3
- Written in
- 2022/2023
- Type
- Exam (elaborations)
- Contains
- Questions & answers
Subjects
-
texas aampm university csce 121 introduction to program design and concepts mystringcpp