• cbazero@programming.dev
      link
      fedilink
      arrow-up
      9
      arrow-down
      1
      ·
      6 months ago

      I guess you ask for C++. There Type* can be null while Type& can’t be null. When it gets compiled Type& is compiled (mostly) to the same machinecode as Type*.

    • Valmond@lemmy.world
      link
      fedilink
      arrow-up
      7
      ·
      6 months ago

      You can pass nullptr in the second example (that is not what OP wrote though, hes second is making a copy).