i didn’t get why reference is used in copy constructor.how it is making a loop like structure?
Reference to copy constructor
Hey @kingshuk441
See basically when you’re passing the argument X like:
Car(Car X)
In such a function call, from the main function, the copy of the Car object E is being passed as X (this is what generally occurs in function calls where we don’t pass arguments by referrence, right?). So basically we need to pass copy of Car E if we write as
Car(Car X)
But we don’t have the copy of Car object, for that purpose itself, we were creating a copy constructor, to create a copy, and basically the argument of copy constructor is requiring copy, which we don’t have yet, so we need to pass Car X by referrence
Hey @kingshuk441
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.