fork(1) download
  1. #include <iostream>
  2.  
  3.  
  4. struct Base
  5. {
  6. Base(){}
  7. Base(const Base&) { std::cout << "gotcha\n"; }
  8. };
  9.  
  10. void test(const Base&)
  11. {
  12. static int i = 0;
  13. std::cout << "Done test " << ++i << "\n";
  14. }
  15.  
  16. struct Derived : Base
  17. {
  18. };
  19.  
  20. struct Foo
  21. {
  22. operator Derived() { return Derived(); }
  23. static Derived moo() { return Derived(); }
  24. };
  25.  
  26. int main()
  27. {
  28. test(Foo());
  29. test(Derived());
  30. test(Foo::moo());
  31. }
  32.  
Success #stdin #stdout 0s 2684KB
stdin
Standard input is empty
stdout
gotcha
Done test 1
Done test 2
Done test 3