Why are you messing with your object in the +operator? +operator should be a const operation.You need to be returning a temporary object instead. If you want the compiler to check for problems like that, declare your function as const.Code:StrType StrType::operator+(const StrType &right) { char *temp = new char[strlen(right.ptr) + strlen(ptr) + 1]; strcpy(temp, ptr); strcat(temp, right.ptr); delete [] ptr; //why are you changing your object? ptr = new char[strlen(temp) + 1]; strcpy(ptr, temp); delete [] temp; return *this; }Additionally, implement a copy constructor. I promise that the one being generated by the compiler is not the one you want.Code://in header StrType operator+(const StrType &) const; //in implementation StrType StrType::operator+(const StrType &right) const