I've been trying to understand the output of below C++ code snippet.
union A
{
struct B
{
int a : 5;
int b : 4;
int c : 3;
}b;
unsigned char e;
}U;
int main()
{
U.e = 10;
std::cout << "a - " << U.b.a << std::endl;
std::cout << "b - " << U.b.b << std::endl;
std::cout << "c - " << U.b.c << std::endl;
system("pause");
return 0;
}
output: a - 10 b - 0 c - 0
Thanks, Rehman