C++ Programming - Constructors and Destructors - Discussion

Discussion Forum : Constructors and Destructors - General Questions (Q.No. 19)
19.
If the copy constructor receives its arguments by value, the copy constructor would
call one-argument constructor of the class
work without any problem
call itself recursively
call zero-argument constructor
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
8 comments Page 1 of 1.

Bhaijaan_manit_mca said:   1 decade ago
Because pass-by-value would invoke the copy constructor :).

Omkar said:   1 decade ago
How it calls it recursively?

Surya said:   1 decade ago
Because to copy the value of called function copy constructor invoked so fun call again and again.

ClickToAshish said:   1 decade ago
Because in Call by value we just pass the value so it will create another object and again calls constructor however if we called using reference it will not invoke further.
(1)

Varunrao.rao@gmail.com said:   9 years ago
In one of the previous question, it was told that copy constructor must receive its arguments only by pass by reference.

Then how it's call itself recursively?
(2)

Vishal said:   7 years ago
How call itself recursively? Please explain.
(1)

Prakas.s said:   4 years ago
@Vishal.

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.
(1)

Arjun Mandavkar said:   4 years ago
@Prakas S.

Great explanation, thank you.
(1)

Post your comments here:

Your comments will be displayed after verification.