#include <iostream>
#include <string>
using namespace std;
/*************************************/
union Union
{
int i;
double d;
char c;
};
/*************************************/
struct Struct
{
Union *wskU;
Union uObj;
Union uObj2;
friend void wpisz( Struct, Union&, int );
friend void wpisz( Struct, Union&, double );
friend void wpisz( Struct, Union&, char );
};
/*************************************/
void wpisz( Struct s, Union &u, int n )
{
s.wskU = &u;
s.wskU -> i = n;
}
void wpisz( Struct s, Union &u, double n )
{
s.wskU = &u;
s.wskU -> d = n;
}
void wpisz( Struct s, Union &u, char n )
{
s.wskU = &u;
s.wskU -> c = n;
}
/*************************************/
int main( void )
{
Struct s;
wpisz( s, s.uObj, 'X' );
wpisz( s, s.uObj2, 666 );
cout << "Znak w pierwszym: " << s.uObj.c << endl;
cout << "Liczba w drugim: " << s.uObj2.i << endl;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwovKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KdW5pb24gVW5pb24KewoJaW50IGk7Cglkb3VibGUgZDsKCWNoYXIgYzsKfTsKLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCnN0cnVjdCBTdHJ1Y3QKewoJVW5pb24gKndza1U7CgkKCVVuaW9uIHVPYmo7CglVbmlvbiB1T2JqMjsKCQoJZnJpZW5kIHZvaWQgd3Bpc3ooIFN0cnVjdCwgVW5pb24mLCBpbnQgKTsKCWZyaWVuZCB2b2lkIHdwaXN6KCBTdHJ1Y3QsIFVuaW9uJiwgZG91YmxlICk7CglmcmllbmQgdm9pZCB3cGlzeiggU3RydWN0LCBVbmlvbiYsIGNoYXIgKTsKCQp9OwovKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8Kdm9pZCB3cGlzeiggU3RydWN0IHMsIFVuaW9uICZ1LCBpbnQgbiApCnsKCXMud3NrVSA9ICZ1OwoJcy53c2tVIC0+IGkgPSBuOwp9CnZvaWQ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