delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/06/21/22:09:46

Message-ID: <358DBC89.46A042BB@cs.com>
Date: Sun, 21 Jun 1998 22:08:09 -0400
From: "John M. Aldrich" <fighteer AT cs DOT com>
Organization: Two pounds of chaos and a pinch of salt.
MIME-Version: 1.0
To: Andrew Deren <aderen AT eecs DOT uic DOT edu>
CC: djgpp AT delorie DOT com
Subject: Re: how do I pass more than one value out of a function???
References: <Pine DOT GSO DOT 3 DOT 96 DOT 980621015613 DOT 20672A-100000 AT oscar DOT eecs DOT uic DOT edu>

Andrew Deren wrote:
> 
> Actually I would disagree with that. Pascal var passing is like c++ pass
> by reference. Passing a pointer is different than passing a reference.
> 
> (I agree that this is more for comp.lang.c)

Actually, your particular point is more for comp.lang.c++, since C
doesn't support pass-by-reference.  Internally, it's all done via
pointers anyway, regardless of the particular language syntax.

There is no functional difference between:

void addp( int *i1, int i2 )
{
    *i1 += i2;
}

and

void addr( int &i1, int i2 )
{
    i1 += i2;
}

They are identical for all intents and purposes, except that in addp(),
the thing i1 points to can be modified.

-- 
---------------------------------------------------------------------
|      John M. Aldrich       | "Sin lies only in hurting other      |
|       aka Fighteer I       | people unnecessarily.  All other     |
|   mailto:fighteer AT cs DOT com   | 'sins' are invented nonsense."       |
| http://www.cs.com/fighteer |                 - Lazarus Long       |
---------------------------------------------------------------------

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019