Alt text:

Image that says:

HOLY SHIT!! IS THAT A MOTHERF*CKING C++ REFERENCE???

int& a = b;

  • xmunk
    link
    fedilink
    arrow-up
    15
    ·
    edit-2
    8 months ago

    In my experience, it’s rare to see int& in day to day as a regular old lvalue… it essentially just allows you to alias a variable to another name. It’s much more common to see them used in function parameters to leverage pass by reference. In C++ pointers usually aren’t particularly useful compared to just passing things by reference since stack variables get auto-gc’d it’s the preferred style of frameworks like Qt and is extremely easy to use.

    Here’s a breakdown if you want more information https://en.cppreference.com/w/cpp/language/reference