#include <iostream>
 
struct A
{
    A() {}
    A( const A& ) { std::cout << "A::copy_constructor is called to make a copy\n" ; }
    A( A&& ) { std::cout << "in this program, this message will not be printed\n" ; }
};
 
void foo( A object ) { std::cout << "foo has recieved a copy of an object\n"  ; }
A bar() { std::cout << "bar - about to return an object by value\n" ; static A a ; return a ; }
 
int main()
{
    std::cout << "about to call bar\n" ;
    A object = bar() ;
    std::cout << "bar has returned\n" ;
 
    std::cout << "\n\nabout to call foo\n" ;
    foo(object) ;
}
 