Why reference can not capture temporary while const ref and rval ref can [duplicate]
问题 This question already has answers here : How come a non-const reference cannot bind to a temporary object? (11 answers) Closed 5 years ago . Why reference can not capture temporary value while const reference and rvalue reference can capture and prolong object life. In other words while two first lines are legal but third not: const string &a = string("a"); string &&b = string("b"); string &c = string("c"); // why illegal? 回答1: Quoting from N1377 Bjarne in his excellent text "The Design and