Help with logic

closed account (jGzURXSz)
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
int funct()
Y y;
return i;
void main()
cout << "i = "<<funct()<<"\n";
It seems an object of type Y must be destroyed before the statement return i;
There may be a few different ways to make that happen.
Topic archived. No new replies allowed.