Tuesday 24 November 2009

Pass by reference vs. pass by value

This one is for myself, as I often forget how to implement pass by reference and pass by value, and what the difference is between them.
Pass by reference:

Declare varible and set it :
SalesLine salesLine = salesLine4

Down-side is if salesLine4 changes - so does salesLine

Pass by value:

SalesLine salesLine;
salesLine.data(salesLine4);

Happy ax-hacking

If salesLine4 changes - salesLine doesn't

No comments: