Hi Dark,

The void main function here should indeed be void, but it is the second function that we must look at. the add_numbers function returns an int, and takes two arguments; two ints in this case and adds them together, returning the result. first and second are simply variable names local to that function which will receive the values that the user passes when calling it. So when we call it from main we say 3 and 5 as our parameters, which means that when the function begins executing the int variable first will have the value 3 and second will have the value 5. In short, the parameter list has variable types and names that get assigned the values that the user calls the function with.


Kind regards,

Philip Bennefall
----- Original Message ----- From: "dark" <d...@xgam.org>
To: <Gamers@audyssey.org>
Sent: Wednesday, March 24, 2010 8:42 PM
Subject: [Audyssey] Return function explain


Appologies, but I'm stil a bit lost on returning  functions.

Could someone please give me a blow by blow on this example from the tutorial sinse other than the alert function and the original void main I'm slightly lost with this one:

void main()
{
int x=add_numbers(3, 5);
alert("Wow", "3 + 5 is... " + x + "!");
}
int add_numbers(int first, int second)
{
int result=first+second;
return result;
}


Really sorry for the question, ---- it might just be me being extremely stupid here.

Beware the grue!

Dark.
---
Gamers mailing list __ Gamers@audyssey.org
If you want to leave the list, send E-mail to gamers-unsubscr...@audyssey.org.
You can make changes or update your subscription via the web, at
http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/gam...@audyssey.org.
If you have any questions or concerns regarding the management of the list, please send E-mail to gamers-ow...@audyssey.org.


---
Gamers mailing list __ Gamers@audyssey.org
If you want to leave the list, send E-mail to gamers-unsubscr...@audyssey.org.
You can make changes or update your subscription via the web, at
http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/gam...@audyssey.org.
If you have any questions or concerns regarding the management of the list,
please send E-mail to gamers-ow...@audyssey.org.

Reply via email to