void function(int &a) { ... }
you're using a reference, not a pointer. It's basically letting the compiler figure out the pointer stuff for you. Doing "a = 2" will indeed set the value of the variable back in the location where you called the function. When you use an actual pointer like this:
void function(int *a) { ... }
doing the same "a = 2" is not going to change the value of a back where you called the function. a is a pointer to an int, so doing "a = 2" changes the location that the pointer is pointing to. If you're trying to change the value of the variable that you passed to the function you need to dereference the pointer by doing "*a = 2", just like Luben and thephoenix said. And of course back in the initial function call, you need to pass the variable like so:
function(&a);
In that case, & is the "address of" operator, not the reference operator. Getting the address of a variable gives you a pointer. Isn't C++ great?

To sum it all up, here's an example:
int a = 0;
refFunc(a); // Good. a now equals 1.
ptrFunc1(&a); // Good. a now equals 2.
ptrFunc2(&a); // Doesn't work. a still equals 2.
ptrFunc1(a); // This should be a compiler error.
refFunc(int &arg) {
arg = 1;
}
ptrFunc1(int *arg) {
*arg = 2;
}
ptrFunc2(int *arg) {
arg = 3; // Setting the value of the pointer, not the intended variable.
}
Make sense?