# include # include # include "icecream.h" iceCreamRecord::iceCreamRecord() { // just put empty strings in both locations nameField[0] = '\0'; flavorField[0] = '\0'; } iceCreamRecord::iceCreamRecord(const string & namestr, const string & flavorstr) { // copy values into the two fields for (unsigned int i = 0; namestr[i] != '\0'; i++) nameField[i] = namestr[i]; nameField[i] = '\0'; for (i = 0; flavorstr[i] != '\0'; i++) flavorField[i] = flavorstr[i]; flavorField[i] = '\0'; } string iceCreamRecord::name() const { // return name field made into a string string result(nameField); return result; } string iceCreamRecord::flavor() const { // return flavor field made into a string string result(flavorField); return result; } int isEmpty(const iceCreamRecord & x) { // field is empty if it has no name component string empty; return x.name() == empty; } int operator == (const iceCreamRecord & left, const iceCreamRecord & right) { // equality between records based only on name return left.name() == right.name(); } void iceCreamRecord::operator = (const iceCreamRecord & right) { strcpy(nameField, right.nameField); strcpy(flavorField, right.flavorField); } ostream & operator << (ostream & out, iceCreamRecord & right) { out << right.name(); out << " and "; out << right.flavor(); //out << right.name() << " and " << right.flavor(); return out; }