C++: difference between ampersand “&” and asterisk “*” in function/method declaration

c++pointersreference

Is there some kind of subtle difference between those:

void a1(float &b) {
    b=1;
};
a1(b);

and

void a1(float *b) {
    (*b)=1;
};
a1(&b);

?

They both do the same (or so it seems from main() ), but the first one is obviously shorter, however most of the code I see uses second notation. Is there a difference? Maybe in case it's some object instead of float?

Best Solution

Both do the same, but one uses references and one uses pointers.

See my answer here for a comprehensive list of all the differences.