Its basically a nifty method of addressing a piece of memory in more than 1 way.....
Code:
#include <iostream>
using namespace std;
union MY_UNION{
unsigned short MyUShort;
long MyLong;
short MyShort;
}MyUnion;
int main(){
MyUnion.MyLong = 562789;
cout << dec << "MyLong = \t" << MyUnion.MyLong;
cout << hex << "\thex - \t0x0" << MyUnion.MyLong << endl;
cout << dec << "MyShort = \t" << MyUnion.MyShort;
cout << hex << "\thex - \t0x0" << MyUnion.MyShort << endl;
cout << dec << "MyUShort = \t" << MyUnion.MyUShort;
cout << hex<< "\thex - \t0x0" << MyUnion.MyUShort << endl;
return 0;
}
Handy occasionally.......