137: return temp;
138: }
139:
140: // changes current string, returns nothing
141: void String::operator+=(const String& rhs)
142: {
143: int rhsLen = rhs.GetLen();
144: int totalLen = itsLen + rhsLen;
145: int i, j;
146: String temp(totalLen);
147: for (i = 0; i<itsLen; i++)
148: temp[i] = itsString[i];
149: for (j = 0; j<rhs.GetLen(); j++, i++)
150: temp[i] = rhs[i-itsLen];
151: temp[totalLen]=\0;
152: *this = temp;
153: }
154:
155: // int String::ConstructorCount = 0;
Output: This program has no output.
Analysis: On line 23 the static member variable ConstructorCount is declared, and on line 155 it is initialized. This variable is incremented in each string constructor.
Listing 20.4 describes an Employee class that contains three string objects. Note that a number of statements are commented out; they will be used in later listings.