why in the case of copy constructor we have to pass the object by reference rather than passing it by value.
Doubt in copy constructor?
hello @mehulbhandari358
It is very essential to pass objects as reference. If an object is passed as value to the Copy Constructor then its copy constructor would call itself, to copy the actual parameter to the formal parameter. Thus an endless chain of call to the copy constructor will be initiated. This process would go on untill the system run out of memory.
Hence, in a copy constructor, the parameter should always be passed as reference.
https://www.quora.com/Why-is-call-by-reference-used-in-a-copy-constructor
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.