A union makes all members share the same memory, only with different representations. I've used this for binary readers as an example (to read structured data):
Code:
class CPointer
{
public:
union
{
void* Void;
char* Char;
short* Short;
int* Int;
float* Float;
}
};
CPointer Pointer;
Pointer.Char = PointToDataSomwhere();
int IntVal1 = *Pointer.Int++;
int IntVal2 = *Pointer.Int++;
float FloatVal1 = *Pointer.Float++;
int IntVal3 = *Pointer.Int++;
float FloatVal2 = *Pointer.Float++;
float FloatVal3 = *Pointer.Float++;
short ShortVal1 = *Pointer.Short++;
int IntVal4 = *Pointer.Int++;
(forgive errors, I'm a C# user nowadays)