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
Discussion:
8 comments Page 1 of 1.
Arjun Mandavkar said:
4 years ago
@Prakas S.
Great explanation, thank you.
Great explanation, thank you.
(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.
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)
Vishal said:
7 years ago
How call itself recursively? Please explain.
(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?
Then how it's call itself recursively?
(2)
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)
Surya said:
1 decade ago
Because to copy the value of called function copy constructor invoked so fun call again and again.
Omkar said:
1 decade ago
How it calls it recursively?
Bhaijaan_manit_mca said:
1 decade ago
Because pass-by-value would invoke the copy constructor :).
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers