cout << "pass by value: " << endl; AcceptVal(ReturnRvalue()); // 应该调用两次拷贝构造函数 cout << "pass by reference: " << endl; AcceptRef(ReturnRvalue()); // 应该只调用一次拷贝构造函数 如果允许的话,是没有Copy的,是因为C++ RVO (Return Value Optimization),详细在https://stackoverflow.com/questions/10476665/avoiding-copy-of-objects-with-the-return-statement 我是用VS跑的