If I have a class:
class Odp
{
int i;
int b;
union
{
long f;
struct
{
WCHAR* pwszFoo;
HRESULT hr;
};
};
}
Union means that, of all values listed, it can only take on one of those values at a time? How does that work in terms of accessing these variables? How would I access hr
directly? If I set hr
, what happens if I try to access f
?
reinterpret_cast
is usable instead of a union most of the time. – Kale