Elektrine lite

← Feed

@Flames5123@sh.itjust.works

Post #3214794

2026-06-09 06:25 UTC

Now that explain the & part of the pointers that I never really understood.

Replies (2)

  • @ZILtoid1991@lemmy.world 2026-06-09 07:03

    The & operator references the value. int i; int* p = &i; In C++, the & at the function argument makes it a reference type (safe pointer). void someFunction(int& refVal) { [...] }

    Open ##3215984

  • *x = dereference or “point to”. Treats the variable x as containing a pointer value. Evaluates to a variable existing at x’s address. &x = reference or “get address of”. Evaluates to the address of x. They’re complimentary operators, so *(&x) cancels out and is equvalent to just x.

    Open ##3230859