Person& operator=(const Person& other)
{
    char* newname = NULL;
    try {
        newname = new char[strlen(other.name)+1];
        strcpy(other.name, name);
        std::swap(name, newname);
        delete [] newname;
        return *this;
    } catch(...) {
        delete [] newname;
        throw;
    }