C++ | Destructors | Question 2

Last Updated :
Discuss
Comments
Predict the output of following C++ progran CPP
#include <iostream>
using namespace std;
 
int i;
 
class A
{
public:
    ~A()
    {
        i=10;
    }
};
 
int foo()
{
    i=3;
    A ob;
    return i;
}
 
int main()
{
    cout << foo() << endl;
    return 0;
}
0
3
10
None of the above
Share your thoughts in the comments