// File: mystring.C // // Implementation of String class #include #include #include #include "mystring.h" int String::idvar=0 ; String::String() { /* do nothing else */ } String::String(char *s) : BString(s) { /* do nothing else */ } String::String(const BString& bs) : BString(bs) { /* do nothing else */ } String::~String() { /* do nothing else */ } Ordered *String::clone() { Ordered *ptr = new String(*this) ; // *this converted to BString& if (ptr == NULL) { cerr << "Oops" << endl ; exit(1) ; } return ptr ; } int String::cmp(Ordered *ptr) { if (ptr == NULL) return 1 ; if ( &idvar != ptr->id() ) { return &idvar < ptr->id() ? -1 : 1 ; } String *p = (String *) ptr ; if (*this < *p) return -1 ; // Bstring < and > if (*this > *p) return 1 ; return 0 ; }