fork download
  1. #include <iostream>
  2. using namespace std;
  3. struct Thing {
  4. Thing (int value) {
  5. cout << "such an awesome " << value << endl;
  6. }
  7. };
  8. union Union {
  9. Union () {}
  10. Thing thing;
  11. };
  12. int main (int, char **) {
  13. Union u;
  14. bool yes;
  15. cin >> yes;
  16. if (yes) {
  17. new (&(u.thing)) Thing(42);
  18. }
  19. return 0;
  20. }
Success #stdin #stdout 0s 3100KB
stdin
1

stdout
such an awesome 42