Can someone explain the guidelines for choosing whether to pass a variable by reference or by const reference?
eg.
When should I do:
"int theFunction( theClass &x);"
And when should I do:
"int theFunction( const theClass &x);"
Thanks for any help
Can someone explain the guidelines for choosing whether to pass a variable by reference or by const reference?
eg.
When should I do:
"int theFunction( theClass &x);"
And when should I do:
"int theFunction( const theClass &x);"
Thanks for any help
If you are not going to modify the class, pass it by const reference, else pass it by ordinary reference.