#ifndef MYSTRING_CLASS_H #define MYSTRING_CLASS_H #include class String { private: char *str; public: String(void) {str=0;} String(const char *s) {str=strdup(s);} String(const String & s) {str=strdup(s.str);} ~String(void) {if(str) delete str;} len() {return strlen(str);} operator=(const char *s) {if(str) delete str; str=strdup(s);} operator=(const String & s) {if(str) delete str; str=strdup(s.str);} operator==(const char *s) {if(str && s) return !strcmp(str, s); return 0;} operator==(const String & s) {if(str && s.str) return !strcmp(str, s.str); return 0;} operator!=(const char *s) {if(str && s) return strcmp(str, s); return 1;} operator!=(const String & s) {if(str && s.str) return strcmp(str, s.str); return 1;} operator<(const char *s) {if(str && s) return (strcmp(str, s) < 0); return 0;} operator<(const String & s) {if(str && s.str) return (strcmp(str, s.str) < 0); return 0;} operator>(const char *s) {if(str && s) return (strcmp(str, s) > 0); return 0;} operator>(const String & s) {if(str && s.str) return (strcmp(str, s.str) > 0); return 0;} friend ostream & operator<<(ostream & os, const String & st) {os << st.str; return os;} friend istream & operator>>(istream & is, String & st) {char temp[256]; is.getline(temp, 256); if (is) st = temp; return is;} }; #endif