You can pass by value if copying is cheap (for example you want to pass an integer or char) or when you know that you have to make a copy anyway. Otherwise passing by reference is cheaper.
You can pass by value if copying is cheap (for example you want to pass an integer or char) or when you know that you have to make a copy anyway. Otherwise passing by reference is cheaper.
yes, but suppose to have a program larger than 100 000 lines of code where I could have many function that pass one char or int; if I did all by value (suppose even in those case by value or by reference has no difference) isn't it bad?
Regards
Passing a primitive data type (char, short, int, long, enum...) by value costs the same as passing it by reference.
J-P Nurmi
Bookmarks