The following seems perfectly logical to me, but isn't valid c++. A union cannot be implicitly cast to one of it's member types. Anyone know a good reason why not?
union u {
int i;
char c;
}
function f(int i) {
}
int main() {
u v;
v.i = 6;
f(v);
}
And can anyone suggest a clean alternative (the cleanest I can come up with is f(v.i);
, which I admit is very clean, but the above just seems even cleaner)