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

  1. // \EXAMPLES\EX0703.H
  2. // a sample class using dynamic memory - String
  3.  
  4. // files in this example:
  5. // EX0703.H      this file -- definition of the class String
  6. // %F,15,EX07031.CPP%EX07031.CPP   member functions of the class String
  7. // %F,15,EX07032.CPP%EX07032.CPP   this file -- main() to exercise this class
  8.  
  9. #include <iostream.h>         // needed or output stream
  10.  
  11. class String {                // data members
  12.   char* text;                    // pointer to the characters
  13.   int len;                       // number of chars in string
  14.   int size;                      // allocated space for chars
  15. public:                       // member functions
  16.   String(int maxlen = 0);        // default constructor
  17.   String( const String& s);      // copy constuctor
  18.   String( char* s);              // convert from char* to string
  19.   ~String();                     // destructor
  20.   // member functions to change, concatenate, compare, copy ...
  21.   void append( const char* t);   // add characters to a string
  22.   ostream& print(ostream& os);   // print characters in a string
  23. };
  24.