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.

30 lines
506 B

#include <iostream>
#define L(s) std::cerr << s << "\n"
struct A {
A() { L("A::A()"); }
A(A&&) { L("A::A(A&&)"); }
A(const A&) { L("A::A(const A&)"); }
~A() { L("A::~A()"); }
};
struct B: A {
B() { L("B::B()"); }
B(A&&) { L("B::B(A&&)"); }
//B(B&&) { L("B::B(B&&)"); }
B(const A&) { L("B::B(const A&)"); }
// B(const B&) { L("B::B(const B&)"); }
~B() { L("B::~B()"); }
};
int main() {
L("A a1;");
A a1;
L("B b1(a1);");
B b1(a1);
L("B b1(b1);");
B b2(static_cast<A&>(b1));
return 0;
}