Re: Passing by reference

From: Michael Gesner (dabion@WPI.EDU)
Date: 03/13/01

> Is passing by reference even possible on circle?

This is more of a question of passing by reference a possibility in C

Yes.... its possible... but its different than in C++

> I have a recursive function that needs to increment a memory location for
> each call that does something.
> I was successful in making it work by adding a global variable.
> But, I'm wondering how I can pass by reference because I can't seem to be
> able to.
> Passing by reference will make much more sense just in case of a screwup
> somewhere in the code. It doesn't make much sense to leave this variable
> lying around useless.

C has pointers to take the place of what you call passing by reference...

Be a little more specific on what you want your function to do...
Specifically... what's the point of this function ?

To help you a little tho...

Say I want to pass an integer value to the function... and have it change
within the function

I define my function as

void reference(int *a){
    /* do whatever */

when you call it, call it using the address of the integer you are
in other words

int main(){

int i = 0;

return 0;

That will allow you to "pass by reference" in C++ terminology.

Otherwise... you need to incorporate C++ into your code... and use g++ to

My suggestion however, is to become familiar with pointers, as the circle
code uses these quite frequently.

Michael Gesner
Lodaren of Rhu-Dina'ar 7777
(yes 17777 still works)

   | FAQ: |
   | Archives: |

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