Prolonging life of a temporary object using const reference
问题 I need a few clarification regarding const reference. From this link: const Foo &myFoo = FuncBar(); const reference extended the life of the local object. But when I checked this link although they used a const reference Sandbox(const string& n) : member(n) {} the lifetime of string "four" did not increase. Sandbox sandbox(string("four")); They used the sentence Only local const references prolong the lifespan. Then in the second link isn't the string "four" local to the main function and