home *** CD-ROM | disk | FTP | other *** search
/ Microsoftware Monthly 19…2 Programming Power Tools / MASO9512.ISO / cpptutor / cpptutor.arj / EXAMPLES / EX10011.H < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-25  |  1.7 KB  |  38 lines

  1. // \EXAMPLES\EX10011.H
  2. //--------------------------------------------------------------
  3. // definition of the class String
  4. //--------------------------------------------------------------
  5.  
  6. //  files in this example:
  7. // EX10011.H       this file
  8. // %F,15,EX10012.H%EX10012.H       definition of the classes
  9. //                                 PhoneNum, List, and ListIter
  10. // %F,15,EX10013.H%EX10013.H       definition of the class PhoneBk
  11. // %F,15,EX10011.CPP%EX10011.CPP   member functions of the class String
  12. // %F,15,EX10012.CPP%EX10012.CPP   member functions of the classes
  13. //                                 PhoneNum, List, and ListIter
  14. // %F,15,EX10013.CPP%EX10013.CPP   member functions of the class PhoneBk
  15. // %F,15,EX1001.CPP%EX1001.CPP      main() to exercise this class
  16.  
  17. #ifndef STRCLASS_H
  18. #define STRCLASS_H
  19.  
  20. #include <iostream.h>         // needed or output stream
  21.  
  22. class String {                // data members
  23.   char* text;                    // pointer to the characters
  24.   int len;                       // number of chars in String
  25.   int size;                      // allocated space for chars
  26. public:                          // member functions
  27.   String(int maxlen = 0);             // default constructor
  28.   String( const String& s);           // copy constuctor
  29.   String( char* s);                   // convert  char* to String
  30.   ~String();                          // destructor
  31.   int compare(const char* t) const;   // compare string to char*
  32.   void append( const char* t);        // add chars to a String
  33.   ostream& print(ostream& os) const;  // print chars in a String
  34.   String& operator=( const String& s);// assignment operator
  35. };
  36.  
  37. #endif
  38.