#include <iostream>
struct A
{
A( ) { std:: cout << this << " constructed via A()\n " ; }
A( const A& ) { std:: cout << this << " constructed via A(const A&)\n " ; }
~A( ) { std:: cout << this << " destructed via ~A()\n " ; }
} ;
struct B
{
A a;
B( const A& a)
: a( a) { std:: cout << this << " constructed via B(const A&)\n " ; }
~B( ) { std:: cout << this << " destructed via ~B()\n " ; }
} ;
int main( )
{
A a;
B b( a) ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKc3RydWN0IEEKewogICAgQSgpIHsgc3RkOjpjb3V0IDw8IHRoaXMgPDwgIiBjb25zdHJ1Y3RlZCB2aWEgQSgpXG4iOyB9CiAgICBBKGNvbnN0IEEmKSB7IHN0ZDo6Y291dCA8PCB0aGlzIDw8ICIgY29uc3RydWN0ZWQgdmlhIEEoY29uc3QgQSYpXG4iOyB9CiAgICB+QSgpIHsgc3RkOjpjb3V0IDw8IHRoaXMgPDwgIiBkZXN0cnVjdGVkIHZpYSB+QSgpXG4iOyB9Cn07CgpzdHJ1Y3QgQgp7CiAgICBBIGE7CgogICAgQihjb25zdCBBJiBhKSAKICAgICAgICA6IGEoYSkgeyBzdGQ6OmNvdXQgPDwgdGhpcyA8PCAiIGNvbnN0cnVjdGVkIHZpYSBCKGNvbnN0IEEmKVxuIjsgfQoKICAgIH5CKCkgeyBzdGQ6OmNvdXQgPDwgdGhpcyA8PCAiIGRlc3RydWN0ZWQgdmlhIH5CKClcbiI7IH0KfTsKCmludCBtYWluKCkKewogICAgQSBhOwogICAgQiBiKGEpOwp9