cpp unions

#include <iostream>
using namespace std;

union SampleUnion {
    int intValue;
    float floatValue;
    char charValue;
};

int main() {
    SampleUnion myUnion;

    myUnion.intValue = 42;
    cout << "Value of intValue: " << myUnion.intValue << endl;

    myUnion.floatValue = 3.14f;
    cout << "Value of floatValue: " << myUnion.floatValue << endl;

    myUnion.charValue = 'A';
    cout << "Value of charValue: " << myUnion.charValue << endl;

    return 0;
}