Hmm...
Fred's example is a good way to think about the difference, but it's not quite the way
Java or C++ defines the terms (although, it seems that most everybody else, including quite a few C textbooks, defines the terms that way, hence all of the confusion about pass-by-reference/pass-by-value in Java)
A Text document is a file in the file System. An Object is an object in the Heap. You can obtain a reference to the text document through a text editor. A URI is the "identifier" of the text document, and this is what displays in the text editor's "Open Files" menu. You can obtain a reference to an Object through any number of means. The memory address in the heap is the "identifier" of the object, and this is what is used in the stack. (Note that you can't see this directly...) You can e-mail a friend the URI of the document, and then he can edit the same document. Your friend can edit the URI to point to a different document if he wishes. Please note that you have not passed the text document. You have passed the reference to the text document by value. You can pass a reference of the object to a method. The method can then operate on the same object. The method can change the reference to point to a different object if it wishes. Please note that you have not passed the object. You have passed the reference to the object by value. You can e-mail a friend the document, and the can edit it. But it is a different document, as it has a different URI. You have passed the document by value. This is not possible in Java, but C++ supports this. You can pass an object on the Stack to a method, and it is a copy of the object that is passed -- There are now two distinct objects on the stack. You have passed the object by value. You e-mail a friend the document, and he edits it and your copy is also changed at the same time. You have passed the document by reference. E-mail systems do not support this. Just as in e-mail, this is not possible in Java. However, C++ supports this. You pass the object to a method, and the method can change the reference and do whatever it feels like, and the original object is affected in the same manner. Example:
Expected output, pass-by-value: "Bonjour, Monde"
Expected output, pass-reference-by-value: "Bonjour, Monde!!!"
Expected output, pass-by-reference: "Hello, World???"
[ March 01, 2005: Message edited by: Joel McNary ]