Hi,
In copy constructor function, Why we are taking parameter as reference?
We are just passing arguments as value.
thanks
Copy constructior
hello @vatsal50
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.