Return from a function

Discussion in 'C++' started by Michael Bell, Feb 25, 2008.

  1. Michael Bell

    Michael Bell Guest

    I am a newbie, and looking through some code which I have been given
    as an example of "how to do things right", I see functions like this:-

    void FunctionName(void)

    but in the function itself, after the "workings" I find :-

    return StructName;
    }


    This seems very strange. It is declared as having no return type, but
    yet it is written to return quite a big thing, and plainly the program
    won't work unless it does return it. What's the explanation?

    Michael Bell

    --
     
    Michael Bell, Feb 25, 2008
    #1
    1. Advertising

  2. Michael Bell wrote:
    > I am a newbie, and looking through some code which I have been given
    > as an example of "how to do things right", I see functions like this:-
    >
    > void FunctionName(void)
    >
    > but in the function itself, after the "workings" I find :-
    >
    > return StructName;
    > }
    >
    >
    > This seems very strange. It is declared as having no return type, but
    > yet it is written to return quite a big thing, and plainly the program
    > won't work unless it does return it. What's the explanation?


    Somebody must have screwed up. Does it compile at all? AFAICT, it
    shouldn't. But then again, you didn't post the complete code...

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
     
    Victor Bazarov, Feb 25, 2008
    #2
    1. Advertising

  3. Michael Bell

    Default User Guest

    Michael Bell wrote:

    > I am a newbie, and looking through some code which I have been given
    > as an example of "how to do things right", I see functions like this:-
    >
    > void FunctionName(void)
    >
    > but in the function itself, after the "workings" I find :-
    >
    > return StructName;
    > }
    >
    >
    > This seems very strange. It is declared as having no return type, but
    > yet it is written to return quite a big thing, and plainly the
    > program won't work unless it does return it. What's the explanation?


    Cut and paste the entire piece of code in question, not your
    interpretation. Then we can see what we really have.




    Brian
     
    Default User, Feb 25, 2008
    #3
  4. Default User wrote:
    > Cut and paste the entire piece of code in question


    Wouldn't that destroy the original? Sounds like a bad idea.
     
    Juha Nieminen, Feb 25, 2008
    #4
  5. Michael Bell

    Default User Guest

    Juha Nieminen wrote:

    > Default User wrote:
    > > Cut and paste the entire piece of code in question

    >
    > Wouldn't that destroy the original? Sounds like a bad idea.


    Har.

    I'm old enough to remember the days when the phrase meant exactly that,
    you cut out the text with scissors or and Exact-o and pasted it into
    your document.




    Brian
     
    Default User, Feb 25, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Seong-Kook Shin
    Replies:
    1
    Views:
    521
    Richard Bos
    Jun 18, 2004
  2. Greenhorn
    Replies:
    15
    Views:
    884
    Keith Thompson
    Mar 6, 2005
  3. Replies:
    4
    Views:
    567
    James Kanze
    Jul 22, 2008
  4. AlexHWGUY
    Replies:
    5
    Views:
    175
    John W. Krahn
    Oct 24, 2006
  5. strout

    Function return function???

    strout, Feb 24, 2005, in forum: Javascript
    Replies:
    17
    Views:
    166
    Jarmo
    Feb 27, 2005
Loading...

Share This Page