What is the difference between making a member function of a class const vs const reference in C++?

Viewed 37

What is the difference between marking a function const vs const& of a class?

For example:

class abc {
Private:
    std::string str;
Public:
    const std::string& foo(const int&) const&;
    const std::string& bar(const int&) const;
}

Is there any difference between them? When would you use one over the other?

0 Answers
Related