#ifndef String_h #define String_h #include #include #include using namespace std; class String { private: char *str_; size_t size_; size_t len_; // construtor privado String( size_t s ) { len_ = 0; size_ = s; str_ = new char[size_]; } public: String( char* s = "" ); ~String() { delete str_; } size_t lenght() { return len_; } // comparacoes int operator==(String& s) { return strcmp(str_, s.str_) == 0; } int operator< (String& s) { return strcmp(str_, s.str_) < 0; } int operator<=(String& s) { return strcmp(str_, s.str_) <= 0; } int operator> (String& s) { return strcmp(str_, s.str_) > 0; } int operator>=(String& s) { return strcmp(str_, s.str_) >= 0; } // atribuicao String& operator=(String& s); String& operator=(char* s); // acesso aos caracteres: char& operator[](int i); // concatenação String& operator+(String& s); // conversao para char* operator const char*() { return str_; } }; #endif