- cross-posted to:
- programmerhumor@lemmy.ml
- cross-posted to:
- programmerhumor@lemmy.ml
cross-posted from: https://lemmy.ml/post/14869314
“I want to live forever in AI”
cross-posted from: https://lemmy.ml/post/14869314
“I want to live forever in AI”
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 &