D
dolphin
Why should we use fun(const Class &B) instead of fun(Class &B)?
Why should we use fun(const Class &B) instead of fun(Class &B)?
dolphin said:Why should we use fun(const Class &B) instead of fun(Class &B)?
Why should we use fun(const Class &B) instead of fun(Class &B)?
1. gives the guarantee that B will not be changed (because you can
only call const member functions)
2. can be called on non-modifiable lvalues (Eg const objects,
temporaries, and for POD's - literals.)
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.