delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/06/21/16:00:32

From: Erik Max Francis <max AT alcyone DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: how do I pass more than one value out of a function???
Date: Sun, 21 Jun 1998 12:39:54 -0700
Organization: Alcyone Systems
Lines: 25
Message-ID: <358D618A.150C3E78@alcyone.com>
References: <Pine DOT GSO DOT 3 DOT 96 DOT 980621015613 DOT 20672A-100000 AT oscar DOT eecs DOT uic DOT edu>
NNTP-Posting-Host: charmaine.alcyone.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Andrew Deren wrote:

> TO return several values just use:
> 
> void foo(int& var1, char& var2, etc...)
> 
> and then you call the function with the vars as regular function.
> foo(myInt, myChar);

Most people would suggest you pass pointers.  This makes the code easily
understandable and it's obvious what's being potentially modified and
what's not.

References in C++ were added to facilitate operator overloading, and
became a standard part of the language.  But under normal circumstances
they should be used exceptionally sparingly (except when passing const
references).

-- 
         Erik Max Francis, &tSftDotIotE / mailto:max AT alcyone DOT com
                       Alcyone Systems / http://www.alcyone.com/max/
  San Jose, California, United States / icbm:+37.20.07/-121.53.38
                                     \
                   Regret it? nope. / Said it? yep.
                                   / Ice Cube

- Raw text -


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