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

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