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)

C++ Interview Questions For Experienced

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Why copy constructor argument should be const in C... >>
<< When are copy constructors called in C++?...