What is the potential risk of passing parameters by reference? 

  • Performance overhead 
  • Inability to return values 
  • Accidental data modification 
  • Pointers become null
Passing parameters by reference gives a function direct access to the original data. This can be risky as inadvertent changes in the function can lead to unintended modifications to the data. Care must be taken to ensure the integrity of the data and to avoid unexpected side effects. This risk doesn't exist when passing parameters by value since the function works with a copy of the data.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *