I have been trying to figure this out and have been unsuccessful. I was wondering if anyone could help me understand this.
"Why does the following code display 5 and not 10? How can you change funct() so that the code displays 10 instead of 5? You can ONLY add to (not remove any part of) funct(). You cannot change the statement i=5; to i=10;"
int i; //global variable
class Y
{
public:
~Y()
{
i=10;
}
};
int funct()
{
i=5;
Y y;
return i;
}
void main()
{
cout << "i = "<<funct()<<"\n";
}