Sender: nate AT cartsys DOT com Message-ID: <36E480A5.3623D33A@cartsys.com> Date: Mon, 08 Mar 1999 18:00:05 -0800 From: Nate Eldredge X-Mailer: Mozilla 4.08 [en] (X11; I; Linux 2.2.1 i586) MIME-Version: 1.0 To: djgpp AT delorie DOT com Subject: Re: New pointer methods being taught References: <36e3ef76 DOT 57929301 AT newshost DOT cc DOT utexas DOT edu> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp AT delorie DOT com Jeramie Hicks wrote: > > In my day (many moons ago), you either had a variable, or a ptr to a > variable. If you needed the address of the variable, you used an & to > get it... but that always occured either in function calls (for > functions that wanted a ptr to a variable as an argument) or on the > right side of an equal sign. > > I've been having coworkers ask me questions about C programming > lately, and I've been kind of suprised at what their professors are > teaching to them. For instance, I saw several times things like: > > char& a; // or > &b = 5; // etc... > > being taught to do simple routine operations. Since I've NEVER used an > amperstand on the left side of the equal sign, what's going on here? > What do these statement do? What's the advantage to doing something > like this? It just seems more confusing then when I learned it, and > they're still doing the same old simple operations, just in a wierd > way. Looks like C++ to me, or else some weird compiler extension. I can't speak to C++ myself, but in vanilla C AFAIK an `&' expression is never an lvalue, so that shouldn't be valid. The declaration looks wrong for C, but for C++ it's a reference variable. Kind of like pass-by-pointer in plain C, except the compiler does the indirection for you. -- Nate Eldredge nate AT cartsys DOT com