Q:

Why copy constructor take the parameter as a reference in C++?

0

Why copy constructor take the parameter as a reference in C++?

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Answer:

A copy constructor is called when an object is passed by value. The copy constructor itself is a function. So if we pass an argument by value in a copy constructor, a call to copy constructor would be made to call copy constructor which becomes a non-terminating chain of calls. Therefore compiler doesn’t allow parameters to be passed by value.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now