There are some important reasons to use const in the copy constructor.
const keyword avoids accidental changes.
You would like to be able to create a copy of the const objects. But if you’re not passing your argument with a const qualifier, then you can’t create copies of const objects.
You couldn’t create copies from temporary reference, because temporary objects are rvalue, and can’t be bound to reference to non-const.
Answer:
There are some important reasons to use const in the copy constructor.
- const keyword avoids accidental changes.
- You would like to be able to create a copy of the const objects. But if you’re not passing your argument with a const qualifier, then you can’t create copies of const objects.
- You couldn’t create copies from temporary reference, because temporary objects are rvalue, and can’t be bound to reference to non-const.
need an explanation for this answer? contact us directly to get an explanation for this answer