[ vlaga @ 25.07.2006. 15:31 ] @
Zanima me sta su reference, zasto su uvedene u c++ i kakva je razlika izmedju reference i pointera?
Dobro bi doslo objasnjenje na primeru, kao i literatura(link) u kojoj je to objasnjeno.
Hvala
[ android~paranoid @ 25.07.2006. 22:48 ] @
Referenca (alijas, upucivac...) je slicna pokazivacu, to je kao druga vrsta identifikatora,
stim da se stalno vezuje za taj deo memorije.

Uvedena je u C++ zbog lakseg koriscenja u odnosu na pointere,
pri prenosu parametara u f-ji po adresi(kad treba da vrate vrednosti)
lakse je ne dereferencirati stalno promenjivu (*p).
[ vlaga @ 26.07.2006. 13:32 ] @
Sad mi je jasno teoretski, ali bih voleo da vidim neki primer.
Hvala
[ darkon @ 26.07.2006. 13:42 ] @
Evo nekoliko linkova:

http://www.embedded.com/story/OEG20010311S0024
http://www.relisoft.com/book/lang/pointer/1ptrref.html
http://www.parashift.com/c++-faq-lite/references.html
http://amitp.blogspot.com/2004/04/c-references-vs-pointers.html

Citat:
Use references when you can, and pointers when you have to.

References are usually preferred over pointers whenever you don't need "reseating". This usually means that references are most useful in a class's public interface. References typically appear on the skin of an object, and pointers on the inside.

The exception to the above is where a function's parameter or return value needs a "sentinel" reference — a reference that does not refer to an object. This is usually best done by returning/taking a pointer, and giving the NULL pointer this special significance (references should always alias objects, not a dereferenced NULL pointer).

Note: Old line C programmers sometimes don't like references since they provide reference semantics that isn't explicit in the caller's code. After some C++ experience, however, one quickly realizes this is a form of information hiding, which is an asset rather than a liability. E.g., programmers should write code in the language of the problem rather than the language of the machine.
[ vlaga @ 27.07.2006. 13:58 ] @
Hvala, linkovi sadrze sve sto mi treba.