Re: Passing by reference

From: Peter Ajamian (
Date: 03/14/01

Leonardo Herrera wrote:
> I'm having problems with some of the semantics used here. I believe
> (please, correct if I'm wrong) that "passing by reference" is very
> possible in C.


> Making a function "take" the reference of a variable
> (already passed) is not possible. ie
> int x=0;
> void f(int *i);
> f(&x); // passing reference...

This is fine.

> void g(int &i);
> g(x);

This is only good in C++, not C.

You can, however, wrap the function in a macro to accomplish the same
thing.  See my previous post in this thread for an example of how to do
this.  You would want to do that if, for example, you were replacing an
existing function.

Regards, Peter

   | FAQ: |
   | Archives: |

This archive was generated by hypermail 2b30 : 12/04/01 PST