#ifndef MYSTRINGH #define MYSTRINGH #include //for ostream and << #include //for size_t #include //for free using namespace std; class mystring { size_t n; //number of characters, not counting the terminating '\0' char *p; //pointer to the 1st character; must be constructed after n public: mystring(const mystring& another); //the copy constructor mystring(const char *s = ""); ~mystring() {free(p);} mystring& operator=(const mystring& another); mystring& operator=(const char *s); char& operator[](size_t i); const char& operator[](size_t i) const; void print() const {cout << p;} friend ostream& operator<<(ostream& ost, const mystring& m) { return ost << m.p; } }; #endif