home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / samples / ioc / wordseq / toyword.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  2.2 KB  |  60 lines

  1. /**********************************************************************
  2. *                                                                     *
  3. *  IBM(R) VisualAge(TM) for C++ for Windows(R), Version 3.5           *
  4. *                                                                     *
  5. *  PID: 5622-880                                                      *
  6. *  - Licensed Material - Program-Property of IBM                      *
  7. *  (C) Copyright IBM Corp. 1991, 1995 - All Right Reserved.           *
  8. *                                                                     *
  9. *  US Government Users Restricted Rights - Use, duplication or        *
  10. *  disclosure restricted by GSA ADP Schedule Contract with IBM Corp.  *
  11. *                                                                     *
  12. *  VisualAge, and IBM are trademarks or registered trademarks of      *
  13. *  International Business Machines Corporation.                       *
  14. *  Windows is a registered trademark of Microsoft Corporation.        *
  15. *                                                                     *
  16. **********************************************************************/
  17.  
  18. /*-------------------------------------------------------------*\
  19. |  toyword.h  -  Class Word for use with coding examples.       |
  20. \*-------------------------------------------------------------*/
  21.  
  22. #include <istring.hpp>
  23.  
  24. class Word  {
  25.  
  26.   IString      ivWord;
  27.   unsigned int ivKey;
  28.  
  29. public:
  30.  
  31.   //Constructor to be used for sample: wordbag.c
  32.   Word (IString const& word, unsigned theLength)
  33.   : ivWord (word), ivKey (theLength) {}
  34.  
  35.   //Constructor to be used for sample: wordseq.c
  36.   Word (IString const& word)
  37.   : ivWord (word) {}
  38.  
  39.   IBoolean operator> (Word const& w1)
  40.            { return ivWord > w1.ivWord;
  41.            }
  42.  
  43.   unsigned int setKey ()
  44.             { return (ivKey = ivWord.length());
  45.             }
  46.  
  47.   IString const& getWord() const
  48.             { return ivWord;
  49.             }
  50.  
  51.   unsigned int const& getKey() const
  52.             { return ivKey;
  53.             }
  54. };
  55.  
  56. // Key access.  The length of the word is the key.
  57. inline unsigned int const& key (Word const& aWord)
  58. { return aWord.getKey();
  59. }
  60.