[CTRL++] Pass value as constant reference if it is not changed in the function

 

Passing values as reference is faster than passing them as a copy (call by value, call by reference), if variables are passed as reference, the content is able to change and return to the calling function, if a function is not intended to change the content when values are passed as reference. The reference should be passed as const to prevent changes which are not intentional. This is also applicable for CONTROL.

main{  dyn_dyn_anytype dda;  //fill dda with a lot of elements...;  printData(dda);}printData(const dyn_dyn_anytype &dda){  //print dda data...}

 

Date added:
Last revised:
Hits:
7.169
Rating:
Rating: 3.8. 36 vote(s).
36 anonymous votes
No rating done at all.
Your vote was '' (0 of 5) You are an anonymous user.
You may log on to do personalized votings
Click the rating bar to rate this item Please log on to do ratings
  • Notification

    FE user cannot be identified! (1403201096)

Tags:
Programming / Scripting, OOP