Reference

From Rosetta Code
Revision as of 01:44, 11 February 2008 by rosettacode>Mwn3d (New page: Category:EncyclopediaA '''reference''' or '''pointer''' is a value associated with a particular place in memory that signifies the beginning of a specific set of data. References are a...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

A reference or pointer is a value associated with a particular place in memory that signifies the beginning of a specific set of data. References are an integral part of linked lists as the "link" in each node. In languages like C and C++, references can be interpreted as raw memory addresses. In languages like Java and C#, the references are typesafe and cannot be interpreted as raw addresses.

Functions may be "call by reference" where its parameters may be remotely modified. If the parameters cannot be modified in this way, the function is a "call by value" function. Example:

main{
   var i = 2
   print i         should print "2"
   function(i)
   print i         prints "2" if function is call by value, "5" if function is call by reference
}

function(var a){
   a = 5
}