Returning a string by reference?

Viewed 24

I'm looking at Linked Lists right now, and I'm wondering why this following function has a string being returned by reference? Why not just by value?

const string& front() const {
    return head->elem; 
}

What is the purpose of const string& vs const string?

0 Answers
Related