book: typo fixes (#204)

This commit is contained in:
Killer_Quinn
2021-08-14 19:27:16 +08:00
committed by GitHub
parent 9ff1deb882
commit 7f46de1a6c
2 changed files with 2 additions and 2 deletions

View File

@@ -345,7 +345,7 @@ int main()
const std::string& lv2 = lv1 + lv1; // legal, const lvalue reference can extend temp variable's lifecycle
// lv2 += "Test"; // illegal, const ref can't be modified
std::cout << lv2 << std::endl; // string,string
std::cout << lv2 << std::endl; // string,string,
std::string&& rv2 = lv1 + lv2; // legal, rvalue ref extend lifecycle
rv2 += "string"; // legal, non-const reference can be modified

View File

@@ -293,7 +293,7 @@ int main()
const std::string& lv2 = lv1 + lv1; // 合法, 常量左值引用能够延长临时变量的生命周期
// lv2 += "Test"; // 非法, 常量引用无法被修改
std::cout << lv2 << std::endl; // string,string
std::cout << lv2 << std::endl; // string,string,
std::string&& rv2 = lv1 + lv2; // 合法, 右值引用延长临时对象生命周期
rv2 += "Test"; // 合法, 非常量引用能够修改临时变量