fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct Bar {
  5. Bar(int, char, int) { std::cout << "bar3\n"; }
  6. Bar(int) { std::cout << "bar1\n"; }
  7. Bar(Bar const&) { std::cout << "bar copy\n"; }
  8. Bar(Bar &&) { std::cout << "bar move\n"; }
  9. ~Bar() { std::cout << "~bar\n"; }
  10. };
  11.  
  12. class Foo {
  13. private:
  14. Bar x;
  15.  
  16. public:
  17. Foo(int a) : x((a==0) ? Bar(12,'a', 34) : Bar(13)) {}
  18. };
  19.  
  20.  
  21. int main() {
  22. // your code goes here
  23. Foo foo0(0);
  24. Foo foo1(1);
  25.  
  26. return 0;
  27. }
Success #stdin #stdout 0s 3096KB
stdin
Standard input is empty
stdout
bar3
bar1
~bar
~bar