c++ * vs & in function declaration

c++, pass-by-reference, pointers, reference

Solution

My rule is simple: use * when you want to show that value is optional and thus can be 0.

Excluding from the rule: all the _obj_s around are stored in containers and you don't want to make your code look ugly by using everywhere `foo(*value);` instead of `foo(value);` So then to show that value can't be 0 put `assert(value);` at the function begin.

Problem

Possible Duplicate: Difference between pointer variable and reference variable in C++ When should I declare my variables as pointers vs objects passed-by-reference? They compile to the same thing in assembly (at least run-time asymptotically) so when should I use which? ``` void foo(obj* param) void foo(obj& param) ```

Original source

Related problems