Zebra0.com

cppFinding half the value explicitly

Finding half the value explicitly

This is the same idea with a function half that receives a variable by reference. The code is slightly different: instead of just an & in the function we use a *. This explicitly says that an address is required. Notice that the calling statement says half(&num); , explicitly specifying the address.

The variable a in half is called a pointer.