CS202 6- ‹#›
Overloading +, += Operators
nIf the + operator was overloaded as a member, the first operand would have to be an object of the class and we should define the member as a const because it doesn’t modify the current object (i.e., the first operand is not modified by this operator!
n
nstring string::operator + (char *lit)const { //1 argument
n    char * temp = new char[len+strlen(lit)+1];
n    strcpy(temp, str);
n    strcat(temp, lit);
n    return string(temp);  //makes a temporary object
n}
n
nDefining member functions as const allows the operator to be used with a constant object as the first operand. Otherwise, using constant objects would not be allowable resulting in a syntax error.