S
SeniorLee
in the book EC++ chapter 11, with this code
( pb is a member of class )
WIdget& WIdget:perator=(const WIdget& rhs)
{
Bitmap *pOrig = pb;
pb = new Bitmap(*rhs.pb);
delete pOrig;
return *this;
}
book says this code is safe for exception, but what if exception
occurs in " pb = new Bitmap(*rhs.pb);" this line?
and it's going to run the next line(delete pOrig. this will result
this object lose its bitmap pointer.
this is right? or wrong?
( pb is a member of class )
WIdget& WIdget:perator=(const WIdget& rhs)
{
Bitmap *pOrig = pb;
pb = new Bitmap(*rhs.pb);
delete pOrig;
return *this;
}
book says this code is safe for exception, but what if exception
occurs in " pb = new Bitmap(*rhs.pb);" this line?
and it's going to run the next line(delete pOrig. this will result
this object lose its bitmap pointer.
this is right? or wrong?