well it does work here is evidence:
Code:
#include <iostream>
using namespace std;
struct char4 {
unsigned char a:4;
unsigned char b:4;
};
union TEST {
char A;
char4 bits;
};
template <typename ChildType>
string ConvtoBin (ChildType eData) {
string bits;
for (int a = 7; a >= 0; a--)
bits += ((eData >> a) & 1)+48;
return bits;
};
int main() {
TEST ch;
ch.A = 100;
cout << "Size of TEST: " << sizeof(TEST) << endl;
cout << "Size of ch: " << sizeof(ch) << endl;
cout << "Character A: " << ch.A << endl;
cout << "Bit a: " << ch.bits.a << endl;
cout << "Bit b: " << ch.bits.b << endl;
cout << "-----------------------------" << endl;
cout << " INTEGER REPRESENTATIONS " << endl;
cout << "-----------------------------" << endl;
cout << "Character A: " << static_cast<int>(ch.A) << endl;
cout << "Bit a: " << static_cast<int>(ch.bits.a) << endl;
cout << "Bit b: " << static_cast<int>(ch.bits.b) << endl;
cout << "-----------------------------" << endl;
cout << " BINARY REPRESENTATIONS " << endl;
cout << "-----------------------------" << endl;
cout << "Character A: " << ConvtoBin(int(ch.A)) << endl;
cout << "Bit a: " << ConvtoBin(ch.bits.a) << endl;
cout << "Bit b: " << ConvtoBin(ch.bits.b) << endl;
cin.get();
}