I have union called f defined as
union uf {
unsigned u;
float f;
}
I have two functions.
void inner_function(uf& in) {
//modify in
}
void outer_function(unsigned& val) {
inner_function(static_cast<uf> (val));
}
can someone please explain me why I am getting "invalid initialization of non-const reference of type 'uf&' from a temporary of type 'uf' error.
So I understand that I can't cast this. So how would someone can fix this issue? I know this works
void outer_function(unsigned& val) {
uf a;
a.u = val;
inner_function(a);
val = a.u;
}
anything more efficient?