I don't quite understand the output of the following code
union foo
{
int a;
double b;
};
int main()
{
foo f;
f.b = 12.0;
cout << f.b << endl;
f.a = 69;
cout << f.b << endl;
cout << f.a << endl;
return 0;
}
Why does it print 12 12 69
The second 12 should have been garbage if I'm not mistaken. I'm using Visual Studio 2010.