| | | | | |

Class String Public Interface (cont.)

class String
{
  public:
    // constructors/destructor
    String  ();                    // construct a null string 
    String  (const char* Cptr);    // construct a string around Cptr
    ~String ();                    // destructor
    String  (const String& S);     // copy constructor
  
    // operators
    String&       operator =   (const String& S);   // assignment operator
    char&         operator []  (unsigned int i) ;       // array access operator
    const char&   operator []  (unsigned int i) const;  // const version

    // builders
    void Wrap    (const char* Cptr);  // wrap Cptr up in a String
    void GetLine (istream& in1);      // read/wrap entire line
    int  SetSize (unsigned int sz, char fill); // keep old data, fill extra space
    void Clear();                     // make string empty (zero size)

    // data accessors
    unsigned int Length  ()               const; // calls strlen(const char*)
    unsigned int Size    ()               const;
    char         Element (unsigned int n) const; // returns the character at place n
                                                 // (returns '\0' if n is out of range)
}  ;

| | Top of Page | 3. C Strings, Proper Type, and String Objects - 8 of 17