9.3 — Lvalue references – Learn C++

PHOTO EMBED

Wed Mar 16 2022 19:35:36 GMT+0000 (Coordinated Universal Time)

Saved by @pham24n #c++

int main()
{
    int x { 5 };
    int& ref { x }; // valid: lvalue reference bound to a modifiable lvalue

    const int y { 5 };
    int& invalidRef { y };  // invalid: can't bind to a non-modifiable lvalue
    int& invalidRef2 { 0 }; // invalid: can't bind to an r-value

    return 0;
}
content_copyCOPY

https://www.learncpp.com/cpp-tutorial/lvalue-references/