i didnot understand why are we supposed to pass reference to copy constructor
Car(Car &X) this line
I didnot understand why are we supposed to pass reference to copy constructor
@abhinavakhil55
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