delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/11/18/22:02:08

From: Erik Max Francis <max AT alcyone DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Return by reference
Date: Tue, 18 Nov 1997 17:43:49 -0800
Organization: Alcyone Systems
Lines: 38
Message-ID: <34724455.1254ED57@alcyone.com>
References: <64t5f7$87c$1 AT prometheus DOT acsu DOT buffalo DOT edu>
NNTP-Posting-Host: newton.alcyone.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Frank Kim wrote:

>           I am migrating to djgpp from Borland C++, and I've found
> that
> djgpp doesn't like return by reference symbol "&". Is this true? thx
> in
> advance.

I can't quite follow what you're asking here.  If you're asking whether
or not a function/member function can return a reference, then the
answer is absolutely yes.

It is, however, a bad idea to return a reference to a local variable,
viz.:

    int &f(void)
    {
        int i;

        // ...

        return i;
    }

This is bad for the same reason that returning a pointer to the same
variable would be bad -- after all, references are just an alternate way
of talking about pointers.

If you didn't mean either of these, the you'll have to post a (small!)
piece of code so that we can tell you why it isn't working.

-- 
         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
                                     \
   "Since when can wounded eyes see / If we weren't who we were"
                                   / Joi

- Raw text -


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