Why copy constructor is passed by reference not by pointer

The syntax of copy constructor says that it should be reference not pointer.

1. Passing by references ensures an actual object is passed to the copy constructor, while a pointer can have NULL value, and make the constructor fail.

2. if we pass a pointer then we have to dereference it. so it will be overhead for the user.

Technically we can write a constructor which pass a pointer; but that is overloaded constructor not copy constructor.

Comments

Popular posts from this blog

STL Questions

Producer Consumer problem using mutex

Interview questions