#include <iostream>
using namespace std;
struct Base {
Base operator+ (Base a) const { cout <<"Base+Base\n"; }
Base& operator= (Base a) const { cout<<"Base=Base\n"; }
};
struct Derived : public Base {
Derived()=default;
Derived(const Base& a) : Base(a) { cout<<"consturct B from A\n"; }
};
int main() {
Base a,b,c;
c=a+b; // Base+Base Base=Base
cout <<endl;
Derived e,f,g;
g = e+f; // Base + Base Construct B from A Base=Base (In fact default Derived=Derived, which uses Base=Base for the Base subobject)
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKc3RydWN0IEJhc2UgewoJQmFzZSBvcGVyYXRvcisgKEJhc2UgYSkgY29uc3QgeyBjb3V0IDw8IkJhc2UrQmFzZVxuIjsgfQoJQmFzZSYgb3BlcmF0b3I9IChCYXNlIGEpIGNvbnN0IHsgY291dDw8IkJhc2U9QmFzZVxuIjsgfQp9OwpzdHJ1Y3QgRGVyaXZlZCA6IHB1YmxpYyBCYXNlIHsKCURlcml2ZWQoKT1kZWZhdWx0OyAKCURlcml2ZWQoY29uc3QgQmFzZSYgYSkgOiBCYXNlKGEpIHsgY291dDw8ImNvbnN0dXJjdCBCIGZyb20gQVxuIjsgfQp9OwoKCmludCBtYWluKCkgewoJQmFzZSBhLGIsYzsgIAoJYz1hK2I7ICAgLy8gQmFzZStCYXNlICAgQmFzZT1CYXNlCgljb3V0IDw8ZW5kbDsgCglEZXJpdmVkIGUsZixnOyAKCWcgPSBlK2Y7ICAvLyBCYXNlICsgQmFzZSAgIENvbnN0cnVjdCBCIGZyb20gQSAgICBCYXNlPUJhc2UgKEluIGZhY3QgZGVmYXVsdCBEZXJpdmVkPURlcml2ZWQsIHdoaWNoIHVzZXMgQmFzZT1CYXNlIGZvciB0aGUgQmFzZSBzdWJvYmplY3QpCglyZXR1cm4gMDsKfQ==