 
                            ...
| Code Block | ||
|---|---|---|
| 
 | ||
| 
Thingy& Thingy::operator=(const Thingy& rhs) {
    if (this != &rhs) {
        delete w;
        w = new Widget(*rhs.w);
    }
    return *this;
}
 | 
Compliant Solution 2
Alternatively, a copy to the original resource can be taken and not deleted until the new value has been established:
...