I'm not really a C++ guru. But I do know they are not equiv. References cannot be null, Because they are really just another name for the same variable. Because of that they cannot be simply declared:
int &r_my_ref = int; must be: int i_my_int = 5; int &r_my_ref = i_my_int; and they cannot be reassigned. Once I say that r_my_ref is another name for i_my_int I cannot change my mind later and have it be another name for something else. Unlike the english language! cool = low_temp; cool = really_hip; So, they are really NOT equivalent. the real value of references (I think) comes when you are passing around HUGE, multiply derived classes.... but I'm just a business programmer, I'll leave that up to the Computer Science guys.... For Sale: Nice Parachute, Used Once, Never Opened, Slightly Stained Michael Comperchio mcmp...@gmail.com On Apr 2, 2009, at 4:11 PM, Tyler Littlefield wrote: > so, passing a reference in c++ is just the equiv of a pointer? > > Thanks, > Tyler Littlefield > Web: tysdomain.com > email: ty...@tysdomain.com > My programs don't have bugs, they're called randomly added features. > > ----- Original Message ----- > From: Michael Comperchio > To: c-prog@yahoogroups.com > Sent: Thursday, April 02, 2009 2:07 PM > Subject: Re: [c-prog] returning arrays > > Remembering the reason for references in c++ is to hide the > implementation of things (whatever things might be). References are > part of the OOP design. The caller has to know nothing about the > function being called. Simply pass in the value, and, since the > compiler can see that it needs a pointer because of the function > footprint, let the compiler convert it to a pointer! > > Don't sweat the small stuff, in fact, don't sweat anything at all. > You'll save a lot on deodorant - Forrest Gump > > Michael Comperchio > mcmp...@gmail.com > > On Apr 2, 2009, at 1:19 PM, Tyler Littlefield wrote: > > > ok. I was thinking c++, you can pass reference which is diff from a > > pointer. > > > > Thanks, > > Tyler Littlefield > > Web: tysdomain.com > > email: ty...@tysdomain.com > > My programs don't have bugs, they're called randomly added features. > > > > ----- Original Message ----- > > From: Michael Comperchio > > To: c-prog@yahoogroups.com > > Sent: Thursday, April 02, 2009 11:11 AM > > Subject: Re: [c-prog] returning arrays > > > > a hunting dog! > > > > A pointer is something that is pointing to a place in memory.... > hence > > pointer. When I learned 'C' (dinosaurs still on earth) I was taught > > there are two ways to pass something to a function. By Value, and By > > Reference. When I pass by value, a copy of the original data is > pushed > > on the stack, and the calling function pops it off. Because it's a > > copy > > only, I can manipulate it to my hearts content, and not change the > > original. When I pass 'by reference' I push the memory location > which > > references (points to, hence pointer) the original data. When my > > function pops the reference off the top of the stack I can > manipulate > > what is pointed to by the memory address, > > > > I miss coding in c for a living. there is sooooo much fun to be had > > with it! > > > > Michael > > > > Commander: "I assure you the project will be completed on time!" > > Darth: "The emperor does not share your optimistic appraisal of the > > situation" > > > > On Apr 2, 2009, at 10:51 AM, Allison Vollmann wrote: > > > > > and what is an pointer? > > > > > > Em 2/4/2009 11:41, Tyler Littlefield escreveu: > > > > > > > > as reference? that's as pointer. > > > > > > > > Thanks, > > > > Tyler Littlefield > > > > Web: tysdomain.com > > > > email: ty...@tysdomain.com <mailto:tyler%40tysdomain.com> > > > > My programs don't have bugs, they're called randomly added > > features. > > > > > > > > ----- Original Message ----- > > > > From: Allison Vollmann > > > > To: c-prog@yahoogroups.com <mailto:c-prog%40yahoogroups.com> > > > > Sent: Thursday, April 02, 2009 8:09 AM > > > > Subject: Re: [c-prog] returning arrays > > > > > > > > pass the array as reference in the function. > > > > > > > > void chArray(int *array) > > > > { > > > > array[0] = 4; > > > > } > > > > > > > > int main(void) > > > > { > > > > int arr[] = {1,2,3}; > > > > ... > > > > chArray(&arr[0]); > > > > ... > > > > return 0; > > > > } > > > > > > > > Em 2/4/2009 10:41, rsashwinkumar escreveu: > > > > > > > > > > this may be very basic but plz., help > > > > > > > > > > How to pass an array(1 Dimensional) to a function, multiply > its > > > > > elements by 2 and return to main function and assign to > another > > > array... > > > > > > > > > > Plz., help urgent... > > > > > > > > > > > > > > > > > > [Non-text portions of this message have been removed] > > > > > > > > > > > > > > > > > > [Non-text portions of this message have been removed] > > > > > > [Non-text portions of this message have been removed] > >