#include <iostream>
#include <vector>
using namespace std;
typedef union Data{
int m;
double u;
long f;
Data(int kj, double lh, long fg)
{
m = kj;
u = lh;
f = fg;
}
Data& operator= (const Data& mydat)
{
m = mydat.m;
u = mydat.u;
f = mydat.f;
return *this;
}
};
struct Example
{
vector <Data> m;
string k;
Example (string info, Data* data)
{
m.push_back(Data(2,-9.32322,-324332));
k = info; *data = m.back();
}
~Example()
{
cout << "Deleted!\n";
}
};
int main()
{
Data* flv = new Data(1,2,3);
std::cout << flv->m << std::endl;
Example doesnotwork("", flv);
std::cout << flv->m << std::endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnR5cGVkZWYgdW5pb24gRGF0YXsKICAgIGludCBtOwogICAgZG91YmxlIHU7CiAgICBsb25nIGY7CiAgICAKICAgIERhdGEoaW50IGtqLCBkb3VibGUgbGgsIGxvbmcgZmcpCiAgICB7CiAgICAgICAgbSA9IGtqOwogICAgICAgIHUgPSBsaDsKICAgICAgICBmID0gZmc7CiAgICB9CiAgICAKICAgIERhdGEmIG9wZXJhdG9yPSAoY29uc3QgRGF0YSYgbXlkYXQpCiAgICB7CiAgICAgICAgbSA9IG15ZGF0Lm07CiAgICAgICAgdSA9IG15ZGF0LnU7CiAgICAgICAgZiA9IG15ZGF0LmY7CiAgICAgICAgCiAgICAgICAgcmV0dXJuICp0aGlzOwogICAgfQp9OwoKc3RydWN0IEV4YW1wbGUKewogICAgdmVjdG9yIDxEYXRhPiBtOwogICAgc3RyaW5nIGs7CiAgICAKICAgIEV4YW1wbGUgKHN0cmluZyBpbmZvLCBEYXRhKiBkYXRhKQogICAgewogICAgICAgIG0ucHVzaF9iYWNrKERhdGEoMiwtOS4zMjMyMiwtMzI0MzMyKSk7CiAgICAgICAgayA9IGluZm87ICpkYXRhID0gbS5iYWNrKCk7CiAgICB9CiAgICAKICAgIH5FeGFtcGxlKCkKICAgIHsKICAgICAgICBjb3V0IDw8ICJEZWxldGVkIVxuIjsKICAgIH0KfTsKCmludCBtYWluKCkKewogICAgRGF0YSogZmx2ID0gbmV3IERhdGEoMSwyLDMpOwogICAgc3RkOjpjb3V0IDw8IGZsdi0+bSA8PCBzdGQ6OmVuZGw7CiAgICBFeGFtcGxlIGRvZXNub3R3b3JrKCIiLCBmbHYpOwogICAgc3RkOjpjb3V0IDw8IGZsdi0+bSA8PCBzdGQ6OmVuZGw7CiAgICByZXR1cm4gMDsKfQ==