Pogledaj jedan post
Old 21.03.2009., 06:32   #11
& ti vraća pointer od instance kad ga koristiš kao operator, npr.
Kod:
struct_foo a;
struct_foo* a_ptr1 = &a;
struct_foo* a_ptr2 = &a;
a_ptr->x = 1;
a_ptr->x = 2;
Ali kad je & u deklaraciji tipa onda je to refrenca
Kod:
struct_foo a;
struct_foo& a_ref1 = a;
struct_foo& a_ref2 = a;
a_ref1.x = 1;
a_ref2.x = 2;
Na kraju će a.x bit 2, isto kao da si radio sa pointerom samo ne koristiš derefrencing operator (-> ili *)
__________________
Our best hope is that the enemy kills so many of us that they become slightly depressed.
leafar is offline  
Odgovori s citatom