When is it valid to return a reference? A reference to const
belongs to book: C++ Primer|Stanley B.Lippman, Josee Lajoie, Barbara E.Moo|5th Edition| Chapter number:6| Question number:31
All Answers
total answers (1)
belongs to book: C++ Primer|Stanley B.Lippman, Josee Lajoie, Barbara E.Moo|5th Edition| Chapter number:6| Question number:31
total answers (1)
When the object is not a local object, then that's fine to return a reference to it.
When we don't want the reference returned from a function to be an lvalue, we should use a reference to `const` as the return type instead.