home *** CD-ROM | disk | FTP | other *** search
- // Chap12_4.cpp (Note that this program doesn't work)
- #include <iostream.h>
- #include <string.h>
-
- class StudentId
- {
- public:
- StudentId(int id = 0)
- {
- value = id;
- cout << "Assigning student id " << value << "\n";
- }
-
- protected:
- int value;
- };
-
- class Student
- {
- public:
- Student(char *pName = "no name", int ssId = 0)
- {
- cout << "Constructing student " << pName << "\n";
- strncpy(name, pName, sizeof(name));
- name[sizeof(name) - 1] = '\0';
- //donÆt try this at home kids. It doesnÆt work
- StudentId id(ssId); //construct a student id
- }
- protected:
- char name[40];
- StudentId id;
- };
-
- int main()
- {
- Student s("Randy", 1234);
- cout << "This message from main\n";
- return 0;
- }
-