Computer Programming
Java Programming
C Programming
C++ Programming

Why copy constructor will take reference object as argument?

User Avatar
Wiki User
2013-04-30 11:27:49

Because if it's not by reference, it's by value. To do that you

make a copy, and to do that you call the copy constructor. But to

do that, we need to make a new value, so we call the copy

constructor, and so on...

(You would have infinite recursion because "to make a copy, you

need to make a copy".)

Copyright © 2020 Multiply Media, LLC. All Rights Reserved. The material on this site can not be reproduced, distributed, transmitted, cached or otherwise used, except with prior written permission of Multiply.