C++ | References | Question 6
Which of the following functions must use reference.
(A) Assignment operator function
(B) Copy Constructor
(C) Destructor
(D) Parameterized constructor
Answer: (B)
Explanation: A copy constructor is called when an object is passed by value. Copy constructor itself is a function. So if we pass 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 pass by value.
See http://quiz.geeksforgeeks.org/copy-constructor-in-cpp/ for details.
Quiz of this Question
Recommended Posts:
- C++ | References | Question 6
- C++ | References | Question 6
- C++ | References | Question 5
- C++ | References | Question 4
- C++ | References | Question 1
- References in C++
- Pointers vs References in C++
- Can references refer to invalid location in C++?
- Default Assignment Operator and References
- C++ | new and delete | Question 1
- C++ | Inheritance | Question 9
- C++ | Templates | Question 2
- C++ | Templates | Question 3
- C++ | Templates | Question 4
- C++ | Templates | Question 5



