"&" uses references as parameters to reduce the cost of copy construction. Because addition does not need to change the original value, and it must be able to accept const objects, so add const. In fact, for such a small class, the cost of copy construction is negligible, and there is no need to use reference to pass value.
"&" uses references as parameters to reduce the cost of copy construction.
Because addition does not need to change the original value, and it must be able to accept const objects, so add const.
In fact, for such a small class, the cost of copy construction is negligible, and there is no need to use reference to pass value.