Just stumbled on this, can anybody explain what is happening here?
struct Foo {
int i;
~Foo() {
std::cout << i << std::endl;
}
};
void bar()
{
Foo f;
f.i = 1;
f = Foo();
f.i = 2;
}
I'm getting the following output:
-85899... (gibberish = "default" value for uninitialized int)
2
where I expected
1
2
Why is it that f.i = 1;
seems to have no effect here?