Well, in a programming exercise I was given the following program, and asked what is your output
using namespace std;
union U1 {
union U2{
unsigned a: 3;
unsigned b: 4;
unsigned c: 1;
}u2;
int d;
void Exibe(unsigned, unsigned, unsigned, int);
}u1;
int main(){
u1.u2.a=2;
u1.u2.a<<=1;
u1.u2.b=16;
u1.u2.b-=4;
u1.u2.c=(u1.u2.b)>>3;
u1.d=17;
cout << u1.u2.a << " " << u1.u2.b << " " << u1.u2.c << " " << u1.d << endl;
}
After the code execution the output is '1 1 1 17', my question is why this output, I researched bit shift and joining with the little that was given in class still can not understand, could help me to understand?