## 18.3 (cont.) Constructors - String Example

E.g., `String` class, with underlying array on heap.

>     class String
>     {
>     public:
>        String(); // Default constructor
>        String(const char p[]); // Simple constructor
>        String(const String& right); // Copy constructor
>        ~String(); // Destructor
>        String& operator=(const String& right); // Assignment operator
>        String& operator+=(const String& right);
>        int length() const;
>        char& operator[](int index);
>        char operator[](int index) const;
>     private:
>        char* buffer;
>        int len;
>     };

prev |top |next