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; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter