// File: record2.C // #include #include #include #include "record2.h" Record::Record() { // Default Constructor printf("Default Constructor: this=%p\n", this) ; str = NULL ; } Record::Record(char *s) { // Alternate Constructor printf("Alternate Constructor: this=%p, s=(%p,\"%s\"),", this, s, s) ; str = strdup(s) ; if (str == NULL) { printf("Ouch\n") ; exit(1) ; } printf("str=(%p,\"%s\")\n", str, str) ; } Record::~Record() { // Destructor // nothing needs to be done. printf("Destructor: this=%p, str=(%p,\"%s\")\n", this, str, str) ; if (str != NULL) free(str) ; } void Record::id() { printf ("id: this=%p, str=(%p,\"%s\")\n", this, str, str) ; }