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 / ch05_5.h < prev    next >
C/C++ Source or Header  |  1992-01-19  |  2KB  |  48 lines

  1.                                // Chapter 5 - Programming exercise 5
  2.  
  3. // This is the header file for a name class that can store a name in
  4. //  three parts and provide a string in any of four different formats
  5. //  which can be used in any database requiring named of persons.
  6. // It is not immediately obvious, but it can also be used to store
  7. //  the name of a city, county, state combination also and provide a
  8. //  string in the correct format to be used in a location program.
  9.  
  10. #ifndef CH05_5_H
  11. #define CH05_5_H
  12.  
  13. class name {
  14. protected:
  15.  
  16.    char first_name[12];
  17.    char middle_name[12];
  18.    char last_name[20];
  19.    int  format;
  20.    static char full_name[35];  // A place to store the full name
  21.  
  22. public:
  23.  
  24.          // Constructors, also set the format to 3
  25.    name(void);                          // Set all three to NULL
  26.    name(char *fn, char *mn, char *ln);  // Set to input fields
  27.  
  28.          // Copy a string into the storage area
  29.    void set_first(char *first_in);
  30.    void set_middle(char *middle_in);
  31.    void set_last(char *last_in);
  32.  
  33.          // Return a pointer to a partial string
  34.    char *get_first(void)  { return first_name; };
  35.    char *get_middle(void) { return middle_name; };
  36.    char *get_last(void)   { return last_name; };
  37.  
  38.          // Return a pointer to a string in the selected format
  39.          //  format = 1 --> John Paul Doe
  40.          //  format = 2 --> J. P. Doe
  41.          //  format = 3 --> Doe, John Paul (default)
  42.          //  format = 4 --> Doe, J. P.
  43.    char *get_full_name(void);
  44.  
  45. };
  46.  
  47. #endif
  48.