// File: stringcell2.C // // Implementation of the StringCell class // No debugging statements #include #include #include #include "stringcell.h" int StringCell::idvar=0 ; // make a copy of this StringCell and return a pointer to the copy // ListCell *StringCell::clone() const { StringCell *sptr = new StringCell(*this) ; if (sptr == NULL) { cerr << "Out of memory in StringCell::clone()" << endl ; exit(1) ; } return sptr ; } // Compare a ListCell with a StringCell // int StringCell::cmp(const ListCell& cell) const { #ifndef NDEBUG cerr << "StringCell: compare function" << endl ; #endif if (cell.id() != &StringCell::idvar) { // if not a StringCell return cell.id() < &StringCell::idvar ? 1 : -1 ; } StringCell *sptr = (StringCell *) & cell ; if (data < sptr->data) return -1 ; if (data == sptr->data) return 0 ; return 1 ; }