Click to See Complete Forum and Search --> : usage of references


ireland
January 31st, 2005, 10:49 AM
what is the usage of references?
why not use const pointers ?

I have seen very little use of references and have never used one
Heres an example of something like I have seen, why not just use pointers and pass them to the function instead.
....
Foo foobar = ....;
..
function ( foobar);
...

Bar (&Foo)
{
//do something
}



What happens in memory with this reference , is a copy of the orignals objects contents made ?

Andreas Masur
January 31st, 2005, 11:56 AM
Well....it provides easier access while dealing with pointers. Many people still have problems to visualize pointers and how to work them. Just...using a reference, it seems more natural since you can access the reference the same way as the original value...

Other than that...references are usually implemented as pointers internally, however, the standard does not specify it...