OverLoadedOpp - #include #include ...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 #include <iostream> #include <string.h> using namespace std class String { public: // constructors String() String(const char *const) String(const String &) ~String() // overloaded operators char & operator[](int offset) char operator[](int offset) const String operator+(const String&) void operator+=(const String&) String & operator= (const String &) friend ostream& operator<< ( ostream& theStream,String& theString) // General accessors int GetLen()const { return itsLen } const char * GetString() const { return itsString } private: String (int) // private constructor char * itsString unsigned short itsLen } // default constructor creates string of 0 bytes String::String() { itsString = new char[1] itsString[0] = '\0' itsLen=0 // cout << "\tDefault string constructor\n" // ConstructorCount++ } // private (helper) constructor, used only by // class methods for creating a new string of // required size. Null filled. String::String(int len) { itsString = new char[len+1] for (int i = 0 i<=len i++) itsString[i] = '\0' itsLen=len // cout << "\tString(int) constructor\n" // ConstructorCount++
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Sheet1 Page 2 }
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern