摘要: 不要将函数的返回值设为&&, std::string &&get(){ std::string s = "str";return std::move(s); } 代码中返回的字符串s在函数返回时就已经离开作用域调用析构函数,函数的得到的返回值其实是一个野指针。 阅读全文
posted @ 2020-05-03 13:16 wa小怪兽 阅读(173) 评论(0) 推荐(0) 编辑