Mooophy/Cpp-Primer

practice 13.56 how to understand ?

wangxinzzz opened this issue · 1 comments

if define a not const & version function ,call this funtion still cause Infinite recursion .what the parctice want to say?

class Foo {
public:
   // Foo sorted() const &;
    Foo sorted() {
       Foo ret;
       return ret.sorted();
   }
};
int main(int arg, char **args) {

    Foo f;
    f.sorted();
    return 0;
}

image

with 13.57 got some idea , does it mean the Foo class still have Foo sorted() && ; so 13.56 will crash and 13.56 run fine