home *** CD-ROM | disk | FTP | other *** search
- // \EXAMPLES\EX0703.H
- // a sample class using dynamic memory - String
-
- // files in this example:
- // EX0703.H this file -- definition of the class String
- // %F,15,EX07031.CPP%EX07031.CPP member functions of the class String
- // %F,15,EX07032.CPP%EX07032.CPP this file -- main() to exercise this class
-
- #include <iostream.h> // needed or output stream
-
- class String { // data members
- char* text; // pointer to the characters
- int len; // number of chars in string
- int size; // allocated space for chars
- public: // member functions
- String(int maxlen = 0); // default constructor
- String( const String& s); // copy constuctor
- String( char* s); // convert from char* to string
- ~String(); // destructor
- // member functions to change, concatenate, compare, copy ...
- void append( const char* t); // add characters to a string
- ostream& print(ostream& os); // print characters in a string
- };