#include <iostream>
#include <string>
using namespace std;
class Person
{
public :
Person( const string& pN = "no name" ) ;
Person( const Person & p) ;
~Person( ) ;
private :
string pName;
} ;
Person:: Person ( const string& pN) : pName( pN)
{
cout << "Constructing Person " << pN << '\n ' ;
}
Person:: Person ( const Person & p) : pName( p.pName )
{
cout << "Copying " << p.pName << " into its own block\n " ;
}
Person:: ~Person( )
{
cout << "Destructing " << pName << '\n ' ;
}
Person fun( Person a)
{
Person ms( a) ;
return ms;
}
int main( )
{
Person p( "Amadis" ) ;
Person s = fun( p) ;
Person ms( "Kansas" ) ;
Person ns = ms;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwpjbGFzcyBQZXJzb24KewogICAgcHVibGljOgogICAgICAgIFBlcnNvbihjb25zdCBzdHJpbmcmIHBOID0gIm5vIG5hbWUiKTsKICAgICAgICBQZXJzb24oY29uc3QgUGVyc29uICZwKTsKICAgICAgICB+UGVyc29uKCk7CiAgICBwcml2YXRlOgogICAgICAgIHN0cmluZyBwTmFtZTsKfTsKClBlcnNvbjo6UGVyc29uKGNvbnN0IHN0cmluZyYgcE4pIDogcE5hbWUocE4pCnsKICAgIGNvdXQgPDwgIkNvbnN0cnVjdGluZyBQZXJzb24gIiA8PCBwTiA8PCAnXG4nOwp9CgpQZXJzb246OlBlcnNvbihjb25zdCBQZXJzb24gJnApIDogcE5hbWUocC5wTmFtZSkKewogICAgY291dCA8PCAiQ29weWluZyAiIDw8IHAucE5hbWUgPDwgIiBpbnRvIGl0cyBvd24gYmxvY2tcbiI7Cn0KClBlcnNvbjo6flBlcnNvbigpCnsKICAgIGNvdXQgPDwgIkRlc3RydWN0aW5nICIgPDwgcE5hbWUgPDwgJ1xuJzsKfQoKUGVyc29uIGZ1bihQZXJzb24gYSkKewogICAgUGVyc29uIG1zKGEpOwogICAgcmV0dXJuIG1zOwp9CgppbnQgbWFpbigpCnsKICAgIFBlcnNvbiBwKCJBbWFkaXMiKTsKICAgIFBlcnNvbiBzID0gZnVuKHApOwogICAgUGVyc29uIG1zKCJLYW5zYXMiKTsKICAgIFBlcnNvbiBucyA9IG1zOwp9Cg==