// StudentId - the following student constructor creates // a non-default student id. #include #include #include class StudentId { public: StudentId(int nId = 0) { this->nId = nId; cout << "Assigning student id " << nId << "\n"; } ~StudentId() { cout << "Destructing student id " << nId << "\n"; } protected: int nId; }; class Student { public: // constructor - create an object with a specified // name and student id Student(char* pszName = "no name", int ssId = 0) : id(ssId) { cout << "Constructing student " << pszName << "\n"; this->pszName = new char[strlen(pszName) + 1]; strcpy(this->pszName, pszName); } ~Student() { cout << "Destructing student " << this->pszName << "\n"; delete this->pszName; pszName = 0; } protected: char* pszName; StudentId id; }; int main() { Student s("Randy", 1234); cout << "This message from main\n"; return 0; }