#include <iostream>
#include <string>
using namespace std;

union U {
	string s;
	int i;
	U (string s) : s(s) { cout << "s is active"<<endl;}
	U (int i) : i(i) { cout << "i is active"<<endl;}
	U() : s() { cout << "s is active by default" <<endl; }
	~U() { cout << "delete... but what ?"<<endl; }
};

int main() {
	U u("hello"); 
	u.s += ", world";  
	cout << u.s <<endl;
	u.i=0; // ouch!!! this is not the active member : what happens to the string ?  
	u.s="goodbye";  // thinks that s is an active valid string which is no longer the case 
	//cout << u.s <<endl;    // ouch  !?
	return 0;
}