Value returning function

This is a discussion on Value returning function within the C++ Programming forums, part of the General Programming Boards category; Can someone explain a value - returning function...

  1. #1
    Registered User
    Join Date
    Aug 2005
    Posts
    15

    Smile Value returning function

    Can someone explain a value - returning function
    Last edited by newbiec++; 09-12-2005 at 09:13 PM.

  2. #2
    Registered User
    Join Date
    Nov 2002
    Posts
    491
    You should by enlightening us on what differs ebtween a value returning funciton and any other function.

  3. #3
    ^ Read Backwards^
    Join Date
    Sep 2005
    Location
    Earth
    Posts
    282
    In your function just "return value;"

    Your function has to be of the type you wish to return.

    Then simply do everything you want your function to do, and end it with:

    Return (whatever you want);

    Return 5;
    Return 5*5;
    Return (5*variable);
    return variable_name;

    Are all valid.

    You can have multiple if statements and each one has a ‘return XXX;’ and your function will end when it returns those.

    When you call that function in your program, say it returns the integer of 5.

    temp = ( 5* function_name());

    Would be the same as

    temp = (5*5);

    *edit*
    Your question changed by the time I hit reply and post....

  4. #4
    Registered User
    Join Date
    Aug 2005
    Posts
    15
    You understood what I was looking for.

    I changed my question to try and clarify what I was looking for. When you are new to C++ it is hard to even know how to phrase your questions to get the answers you are looking for.

    Thanks for your reply

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem in returning value from the dll exported function
    By dattaforit in forum Windows Programming
    Replies: 2
    Last Post: 12-04-2006, 04:30 AM
  2. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  3. returning pointers from a function
    By curlious in forum C++ Programming
    Replies: 2
    Last Post: 12-28-2003, 11:37 PM
  4. structure vs class
    By sana in forum C++ Programming
    Replies: 13
    Last Post: 12-02-2002, 07:18 AM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 06:06 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21