roon@lemmy.ml to Programmer Humor@programming.devEnglish · 5 months ago"I want to live forever in AI"lemmy.mlimagemessage-square58fedilinkarrow-up1549arrow-down120file-text
arrow-up1529arrow-down1image"I want to live forever in AI"lemmy.mlroon@lemmy.ml to Programmer Humor@programming.devEnglish · 5 months agomessage-square58fedilinkfile-text
minus-squarepewpew@feddit.itlinkfedilinkarrow-up9·5 months agoWhats the difference between void fn(Type& var) and void fn(Type* var)?
minus-squarecbazero@programming.devlinkfedilinkarrow-up7·5 months agoI 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*.
minus-squareValmond@lemmy.worldlinkfedilinkarrow-up7·5 months agoYou can pass nullptr in the second example (that is not what OP wrote though, hes second is making a copy).
minus-squarepewpew@feddit.itlinkfedilinkarrow-up3·5 months agoThanks, I was Just curious. I knew what * did but I wasn’t sure about &
Whats the difference between
void fn(Type& var)
andvoid fn(Type* var)
?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*.
You can pass nullptr in the second example (that is not what OP wrote though, hes second is making a copy).
Thanks, I was Just curious. I knew what * did but I wasn’t sure about &