Programming > CODING SOLUTION > 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
Buy NowInstant download
We Accept:
Can't find what you want? Try our AI powered Search
Connected school, study & course
About the document
Uploaded On
Apr 28, 2023
Number of pages
3
Written in
All
This document has been written for:
Uploaded
Apr 28, 2023
Downloads
0
Views
146
Scholarfriends.com Online Platform by Browsegrades Inc. 651N South Broad St, Middletown DE. United States.
We're available through e-mail, Twitter, Facebook, and live chat.
FAQ
Questions? Leave a message!
Copyright © Scholarfriends · High quality services·