fork download
#include 
#include 

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  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;
}
Success #stdin #stdout 0s 3032KB
stdin
Standard input is empty
stdout
3
-324332
Deleted!