A function can only return ONE value.
Quote:
I understand functions...I just don't know when to use which type of the pointers and I would also like a better understanding of them.
I'd say the most common reason for using pointers is to get-around the fact that a function can only return one value. By using a pointer, a function can "get to" all of the elements in an array, or access an entire structure or object.
A single variable can only hold one value. However, a single pointer can point-to an entire array, or an entire structure or object.
Well... Actually, the pointer only holds ONE address... the first memory location used by the array/structure/object. But, these things are stored sequentially in memory, so if you can find the first element in the array you can get to all of the other elements. The compiler knows how to find all of the stuff in a structure or object, given the starting address.
Most beginning C++ books will introduce pointers with a swap() function...
i.e. Starting with X=5 and Y=10. The function "swaps" the values so that X=10 and Y=5.
A function could return either a modified X or Y, but not both!
In order for a function like swap() to work, you need to pass the addresses of the variables into the function. You can do this with pointers or references.
Full disclosure - References are easier to use are generally preferred over pointers when you have a choice.