If copy constructor were to use actual class object and not the reference, then it would need to make a copy. And to do that, it would need to call the copy constructor. And to do that, ... ==> Infinite recursion!
On Jul 21, 12:08 pm, mallesh <[email protected]> wrote: > In C++ Why is it that copy constructor uses only reference as > parameter and not the actual class? > I was given a hint that it has got something to do with stack. I think > it has got something to do with reentrant functions. > > In C also., I think the same thing happens when we pass struct as > parameter to a function, instead of copying the whole structure on to > stack, it takes struct variable's address. > > Can you please explain why this is so? > > -Thanks and regards, > Mallesh -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
