basic_content/pointer_refer/copy_construct.cpp 里面有些问题
Author: LiuDong137816Created Aug 2, 2024Updated Aug 2, 2024
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跑的
Source: Light-City/CPlusPlusThings