Can someone explain a value - returning function
Can someone explain a value - returning function
Last edited by newbiec++; 09-12-2005 at 08:13 PM.
You should by enlightening us on what differs ebtween a value returning funciton and any other function.
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....
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