home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_09_06 / 9n06060b < prev    next >
Text File  |  1991-02-25  |  1KB  |  60 lines

  1. //  class StructThing    --  a struct thing derived from
  2. //                class Thing.
  3. //
  4. //    Version 1.01    --  2/25/91
  5. //
  6. //    Michael Kelly    --  Author
  7. //
  8. #include <stdio.h>
  9. #include <string.h>
  10. #include "th_struc.hpp"
  11.  
  12. void StructThing::print()   
  13.     printf(
  14.       "%d %s\n", 
  15.       ((a_struct)*this).id, 
  16.       ((a_struct)*this).key
  17.     );
  18. }
  19.  
  20. StructThing::operator ==(Thing &some_thing) 
  21.     return ( type() == some_thing.type() ) ?
  22.       ( strcmp( ((a_struct *)ptr())->key,
  23.      ((a_struct *)some_thing.ptr())->key) == 0 ) : 0; 
  24. }
  25.  
  26. StructThing::operator !=(Thing &some_thing) 
  27.     return !( *this == some_thing ); 
  28. }
  29.  
  30. StructThing::operator < (Thing &some_thing) 
  31.     return ( type() == some_thing.type() ) ?
  32.       ( strcmp( ((a_struct *)ptr())->key,
  33.      ((a_struct *)some_thing.ptr())->key) <  0 ) : 0; 
  34. }
  35.  
  36. StructThing::operator <=(Thing &some_thing) 
  37.     return ( type() == some_thing.type() ) ?
  38.       ( strcmp( ((a_struct *)ptr())->key,
  39.      ((a_struct *)some_thing.ptr())->key) <= 0 ) : 0; 
  40. }
  41.  
  42. StructThing::operator > (Thing &some_thing) 
  43.     return ( type() == some_thing.type() ) ?
  44.       ( strcmp( ((a_struct *)ptr())->key,
  45.      ((a_struct *)some_thing.ptr())->key) >  0 ) : 0; 
  46. }
  47.  
  48. StructThing::operator >=(Thing &some_thing) 
  49.     return ( type() == some_thing.type() ) ?
  50.       ( strcmp( ((a_struct *)ptr())->key,
  51.      ((a_struct *)some_thing.ptr())->key) >= 0 ) : 0; 
  52. }
  53.