argh!
let's try to clear this up.
first, a reference IS a pointer. say it with me. a reference is a pointer. the only difference is the way the language presents them to the user.
a pointer is an unsigned integer of some sort (depends on your machine / compiler / language / pointer type). it's a memory address.
in c, there are no references. to a function, you can pass pointers or you can pass copies. if you type (&c), that means "the address of c"
in c++, the reference syntax was added. this is an 'implicit pointer'. when you declare a function that takes a reference, that means that it implicitly grabs the address (a pointer) of the parameter passed to it, instead of making a copy. this is pretty much a convenience feature for the programmer.
java mangles the c++ reference / pointer / stack variable concept. it takes all three and merges them into one concept and removes explicit pointers, and does several things in the background that the programmer is not necessarily aware of.
Code:
void test()
{
MyClass m;
// this is a pointer! on the stack of this function, it is a 32bit integer
// in c, this would be "MyClass *m" (pointer to MyClass)
m = new MyClass();
// 1) a new MyClass object is allocated on the heap
// in c: m = malloc(sizeof(MyClass));
// 2) MyClass constructor is called
// c: m->MyClass();
// 3) m is assigned the value of the newly allocated memory (m is now a pointer to this memory)
// 4) the new object's 'reference count' variable in incremented.
// c: ((Object *)m)->ref_count++;
m.val = 1;
// this is an implicit pointer calculation
// ((address stored in m)(+offset of 'MyClass::val')) = 1
// c: m->val = 1;
foo(m);
// m (a pointer) is pushed onto the call stack. function foo can now use it to reference that memory.
return;
// the reference count of the object pointed to by m is decremented
// if reference count reaches zero, the memory is ready for deallocation by the garbage collector
// c: ((Object *)m)->ref_count--;
}