// CSE 333 Su12 Lecture 11 demo: Str.h // Perkins // Specification of a simple string class. // A Str object wraps an ordinary C-string to make // a C++ object with basic operations. #ifndef _STR_H_ #define _STR_H_ class Str { public: // constructors // create empty string Str(); // create Str from c-string s Str(const char *s); // copy constructor - initialize this to be a copy of s Str(const Str &s); // destructor ~Str(); // return length of this string int length() const; // return a new c-string allocated on the heap with // a copy of this Str's string data char * c_str() const; // append contents of s to the end of this string void append(const Str &s); // string assignment Str & operator=(const Str &s); private: // Str representation char *st_; // c-string on heap with data bytes terminated by \0 }; #endif