Skip to content

Commit

Permalink
Update ex13_28.cpp
Browse files Browse the repository at this point in the history
Please refer to: http://stackoverflow.com/questions/615355/is-there-any-reason-to-check-for-a-null-pointer-before-deleting
I don't think we need to check nullptr before delete.
  • Loading branch information
clare-lsy committed May 3, 2016
1 parent 32a8b81 commit faf6b92
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions ch13/ex13_28.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,8 @@ TreeNode& TreeNode::operator=(const TreeNode &rhs)
{
++*rhs.count;
if (--*count == 0) {
if (left) {
delete left;
}
if (right) {
delete right;
}

delete left;
delete right;
delete count;
}
value = rhs.value;
Expand Down

0 comments on commit faf6b92

Please sign in to comment.