The default case is to work by value:
void doThing(int num) { num++; }
In this case 'num' is a copy of whatever you pass in when calling the function.
int derp = 1;
doThing(derp);
//derp still equals 1 because it was a copy that got incremented
If you want to be able to modify the original value then you can pass by reference:
void doThingByRef(int& num) { num++; }
Now 'num' is effectively a direct alias of whatever you pass in:
int derp = 1;
doThing(derp);
//derp now equals 2
There's another case to consider... What if the thing you're passing in is large, but you don't want to modify it?
You don't want to do an unnecessary copy, so you may use a reference, but that suggests that you're modifying the item within the function. In this case you could use a const reference:
void doThingByConstRef(const BigThing& thing) { ??? }
This lets you read 'thing' but not modify it (you'll get a compile error).
These are the basics of reference semantics. Pointers are similar, but they have some additional properties:
1) A pointer is "nullable". That is, it can be set to 'nulllptr' in order to indicate that it doesn't actually point to anything.
2) A pointer is "reseatable". That is, it can be modified to point at something else.
A note about pointers and constness:
int* num; //the pointer can be changed and the int that it points to can be changed
const int* num; //the pointer can be changed but the int that it points to can not
int* const num; //the pointer can not be changed but the int that it points to can be (probably use a reference instead in this case)
const int* const num; //neither the pointer or the pointed-to int can be changed (probably just use a const reference instead)
Be careful about returning pointers and references from functions. If the thing that you're referring to is destroyed or moved then you end up with a dangling reference/pointer, and that's no fun at all.
So the basic rule of thumb here is:
Use value semantics by default.
Use references when you want references.
Use pointers when you want references that are reseatable and/or nullable.
Cheers.