Programming > CODING SOLUTION > Texas A&M University _ CSCE 121 Introduction to Program Design and Concepts MyString.cpp. (All)
Texas A&M University _ CSCE 121 Introduction to Program Design and Concepts MyString.cpp. 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[other.capacity()]; sizePriv = other.length(); capacityPriv = other.capacity(); for (size_t i = 0; i <= other.length(); ++i){ cString[i] = other.cString[i]; }MyString& MyString::operator=(MyString& other){ if (this != &other){ delete[] cString; cString = new char[other.capacity()]; sizePriv = other.length(); capacityPriv = other.capacity(); for (size_t i = 0; i <= other.length(); ++i){ cString[i] = other.cString[i]; } [Show More]
Last updated: 1 year ago
Preview 1 out of 3 pages
Buy this document to get the full access instantly
Instant Download Access after purchase
Add to cartInstant download
We Accept:
Connected school, study & course
About the document
Uploaded On
Apr 28, 2023
Number of pages
3
Written in
This document has been written for:
Uploaded
Apr 28, 2023
Downloads
0
Views
38
In Browsegrades, a student can earn by offering help to other student. Students can help other students with materials by upploading their notes and earn money.
We're available through e-mail, Twitter, Facebook, and live chat.
FAQ
Questions? Leave a message!
Copyright © Browsegrades · High quality services·