Confusion over C++ pointer and reference topic
问题 What is the difference between the following parameter passing mechanisms in C++? void foo(int &x) void foo(int *x) void foo(int **x) void foo(int *&x) I'd like to know in which case the parameter is being passed by value or passed by reference. 回答1: void foo(int &x) passes a reference to an integer. This is an input/output parameter and can be used like a regular integer in the function. Value gets passed back to the caller. void food(int *x) passes a pointer to an integer. This is an input