home *** CD-ROM | disk | FTP | other *** search
- // \EXAMPLES\EX08061.H
- // a sample class using dynamic memory - String
- //--------------------------------------------------------------
-
- // files in this example:
- // EX08061.H this file
- // %F,15,EX08062.H%EX08062.H definition of class PhoneNum
- // %F,15,EX08063.H%EX08063.H definition of List and ListIter
- // %F,15,EX08064.H%EX08064.H definition of class PhoneBk
- // %F,15,EX08061.CPP%EX08061.CPP member functions of class String
- // %F,15,EX08062.CPP%EX08062.CPP member functions of class PhoneNum
- // %F,15,EX08063.CPP%EX08063.CPP member functions List and ListIter
- // %F,15,EX08064.CPP%EX08064.CPP member functions of class PhoneNum
- // %F,15,EX0806.CPP%EX0806.CPP main to exercise PhoneBk class
-
- //--------------------------------------------------------------
- #ifndef STRCLASS_H
- #define STRCLASS_H
-
- #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 char* to String
- ~String(); // destructor
- int compare(const char* t) const; // compare string to char*
- void append( const char* t); // add chars to a String
- ostream& print(ostream& os) const; // print chars in a String
- String& operator=( const String& s);// assignment operator
- };
-
- #endif
-