home *** CD-ROM | disk | FTP | other *** search
- // Chap12_3.cpp
- #include <iostream.h>
- #include <string.h>
-
- int nextStudentId = 0;
- class StudentId
- {
- public:
- StudentId()
- {
- value = ++nextStudentId;
- cout << "Assigning student id " << value << "\n";
- }
- protected:
- int value;
- };
-
- class Student
- {
- public:
- Student(char *pName = "no name")
- {
- cout << "Constructing student " << pName << "\n";
- strncpy(name, pName, sizeof(name));
- name[sizeof(name) - 1] = '\0';
- }
- protected:
- char name[40];
- StudentId id;
- };
-
- int main()
- {
- Student s("Randy");
- return 0;
- }
-