<<< | Index | >>> |
Few good reasons to use const reference in function arguments:
Avoids copying overhead, saving space and time
Preserves caller's peace of mind
Makes altering object (through reference) a compiler error.
Should always be the first choice when passing non-mutable objects:
void print_point( Point const& pt )
Pointer should probably be the first choice when passing mutable objects. Some people argue that programs should never use non-const references for readability reasons.
<<< | Index | >>> |