home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 353_02 / answers / ch07_4.h < prev    next >
C/C++ Source or Header  |  1992-01-19  |  877b  |  31 lines

  1.                                // Chapter 7 - Programming exercise 4
  2.  
  3. #ifndef CH07_4_H
  4. #define CH07_4_H
  5.  
  6. class new_name : public name {
  7.  
  8.    char sex;
  9.  
  10. public;
  11.  
  12.          // Constructor to set all data to NULL.  This will also
  13.          //  call the name constructor with no parameters.
  14.    new_name(void) { sex = ' '; };
  15.  
  16.          // Constructor to set sex to blank and pass the name
  17.          //  to the parent class via a member initializer.
  18.    new_name(char *fn, char *mn, char *ln) :
  19.                                  name(fn, mn, ln) { sex = ' '; };
  20.  
  21.          // This sets the sex to the input value, if it is either
  22.          //  'M' or 'F', otherwise it leaves it blank and returns
  23.          //  an error value of zero.
  24.    int set_sex(char input_sex);
  25.  
  26.          // This retrieves the value stored
  27.    char get_sex(void) { return sex; };
  28. };
  29.  
  30. #endif
  31.