P
puzzlecracker
Why should the copy constructor take a const reference and not just a
const?
If efficiency is no longer an issue, say size of the object won't
noticeably degrade performance, is it because we can assign temp
object only to const reference, and not just const?
class string {
public;
string();
operator char *();
string (const string & )
};
Say, we have string s="hello";
wouldn't that work if copy ctor took const?
I just don't see any reasons other than efficiency.
Thanks
const?
If efficiency is no longer an issue, say size of the object won't
noticeably degrade performance, is it because we can assign temp
object only to const reference, and not just const?
class string {
public;
string();
operator char *();
string (const string & )
};
Say, we have string s="hello";
wouldn't that work if copy ctor took const?
I just don't see any reasons other than efficiency.
Thanks