C++ | Destructors | Question 2
Predict the output of following C++ progran
(D) None of the above
Explanation: While returning from a function, destructor is the last method to be executed. The destructor for the object “ob” is called after the value of i is copied to the return value of the function. So, before destructor could change the value of i to 10, the current value of i gets copied & hence the output is i = 3. See this for more details.
Quiz of this Question