[ create a new paste ] login | about

Link: http://codepad.org/DwGaC3uF    [ raw code | output | fork ]

C++, pasted on Nov 1:
#include <string>
#include <iomanip>
#include <iostream>
using namespace std;

class cString : public string{
    public:
    cString(){
        cout<<"DC : "<<hex<<(*this)<<endl;
    }
    ~cString(){
        cout<<"DD : "<<hex<<(*this)<<endl;
    }
};

union test
{
    cString s1;
    cString s2;
};

int main(){
    test p;
    p.s1 = "test";
    cout<<p.s1<<endl;
    cout<<p.s2<<endl;
    return 0;
}


Output:
1
2
Line 18: error: member 'cString test::s1' with constructor not allowed in union
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: