home *** CD-ROM | disk | FTP | other *** search
/ C++ for Dummies (3rd Edition) / C_FD.iso / CHAP10 / CHAP10_2.CPP < prev    next >
C/C++ Source or Header  |  1996-09-02  |  862b  |  61 lines

  1. // Chap10_2.cpp
  2. #include <iostream.h>
  3. class Student
  4. {
  5.   public:
  6.    Student()
  7.    {
  8.       cout << "constructing student\n";
  9.       semesterHours = 0;
  10.       gpa = 0.0;
  11.    }
  12.   ~Student()
  13.    {
  14.       cout << "destructing student\n";
  15.    }
  16.    //...other public members...
  17.  
  18.   protected:
  19.    int   semesterHours;
  20.    float gpa;
  21. };
  22.  
  23. class Teacher
  24. {
  25.   public:
  26.    Teacher()
  27.    {
  28.       cout << "constructing teacher\n";
  29.    }
  30.   ~Teacher()
  31.    {
  32.       cout << "destructing teacher\n";
  33.    }
  34. };
  35.  
  36. class TutorPair
  37. {
  38.   public:
  39.    TutorPair()
  40.    {
  41.       cout << "constructing tutor pair\n";
  42.       noMeetings = 0;
  43.    }
  44.   ~TutorPair()
  45.    {
  46.       cout << "destructing tutor pair\n";
  47.    }
  48.  
  49.   protected:
  50.    Student s;
  51.    Teacher t;
  52.    int     noMeetings;
  53. };
  54.  
  55. int main()
  56. {
  57.    TutorPair tp;
  58.    cout << "back in main\n";
  59.    return 0;
  60. }
  61.