Reply to Re: if $a =& $b is assignment by reference, why don't you need to dereference it?

Your name:

Reply:


Posted by Summercool on 09/28/07 15:30

First of all, I think in the very traditional and basic form of
"reference", it means "pointers".

So that's why in C,

when you say

int *ip;

i is a pointer or "reference" to an integer. and that's why when you
use it to get back the integer, you need to do *ip and that's called
"dereference".

So in C++, it seems that there is a different kind of reference, and
that's like an alias type of reference? So in C++, Java, and PHP, you
can have

int i = 10
int &j = i
printf "%d", j and you get 10?
j = 20
printf "%d %d", i, j and both are 20 now?

that's different from the traditional pointer reference

a = 10; b = 20
int *ip = &a // ip pointers to an integer
int *jp = ip // jp pointers to the same integer
printf "%d", *jp
*jp = 20
printf "%d %d", *ip, *jp

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация