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

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