Copy Constructor arguments

What is importance of const. pointer in copy constructor?
the reason for constant is that in copy constructor u never need to change the value of the passed object so to avoid accidental change it is passed as a constant

Why Call by  Reference :

Think of what happens if it’s not a reference. The object gets passed as a copy. But to get passed as a copy, the copy constructor would be
called. That copy constructor gets its value by copy, so the copy
constructor must be called, for which the copy constructor would need to be called, which needs….

This will result in an infinite loop.

When is copy constructor called ?

 

Leave a Reply

Your email address will not be published. Required fields are marked *