QUOTE(net nerd865 @ 8 Aug, 2008 - 08:53 PM)

Ok. So basically a data type reference returns a pointer to the data type.
Almost, although a closer comparison might be 'const pointer' Although they're not really that either. A reference is like an alias (a nickname) for an object or variable which already exists somewhere else in the program. references allow objects to be directly accessed beyond their usual scope.
Consider this code
cpp
void foo(int& bar)
{
bar = 5;
}
int main()
{
int num = 3;
foo( num );
}
The
foo function has
direct access to the variable called 'num' - even though the foo function should not even be able to see 'num' - the reference mechanism has caused the compiler to extend the visibility of the object owned by 'num' to the foo function.
Conceptually, its the same idea as a pointer, the big difference is that pointers in C++ are objects themselves, who's values can change at runtime just like any normal object. A reference has no size of its own, and is set-in-stone (Which can get tricky if you attempt to mix references with dynamically allocated memory, since its still possible to have a dangling reference)
This post has been edited by Bench: 8 Aug, 2008 - 12:35 PM