You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
506B

  1. #include <iostream>
  2. #define L(s) std::cerr << s << "\n"
  3. struct A {
  4. A() { L("A::A()"); }
  5. A(A&&) { L("A::A(A&&)"); }
  6. A(const A&) { L("A::A(const A&)"); }
  7. ~A() { L("A::~A()"); }
  8. };
  9. struct B: A {
  10. B() { L("B::B()"); }
  11. B(A&&) { L("B::B(A&&)"); }
  12. //B(B&&) { L("B::B(B&&)"); }
  13. B(const A&) { L("B::B(const A&)"); }
  14. // B(const B&) { L("B::B(const B&)"); }
  15. ~B() { L("B::~B()"); }
  16. };
  17. int main() {
  18. L("A a1;");
  19. A a1;
  20. L("B b1(a1);");
  21. B b1(a1);
  22. L("B b1(b1);");
  23. B b2(static_cast<A&>(b1));
  24. return 0;
  25. }