What happens when an object is passed by reference?
Asked In Exam: BPSC TRE 3.0
Options
- A. Destructor is called when called explicitly
- B. Destructor is called at end of function
- C. Destructor is not called
- D. Destructor is called when function is out of scope
Correct Answer (Detailed Explanation is Below)
C. Destructor is not called
Detailed Explanation
Explanation:
In C++, when an object is passed by reference, no new copy of the object is created.
Since no new object is created:
The function simply works with the original object.