How call by reference differs from call by pointer with an example?
Answers
Answered by
4
Call by reference and call by pointer do the exact same thing, ideally.
The only difference between them is the fact that a pointer can be null, or maybe pointing to invalid places in memory, while references are never null. Also, a pointer can be re-assigned while reference cannot be, and must be assigned at initialization only. So, the rule of thumb being — use references when you can, and pointers when you have to.
Similar questions
Computer Science,
7 months ago
Math,
1 year ago