Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Creating Functions

Author
Message
Cuddle Bunniezzz 12
15
Years of Service
User Offline
Joined: 14th Jan 2009
Location: Buffalo, NY
Posted: 24th Feb 2009 22:32
I know this is kind of more of a C++ question, but how to I create functions, I'm really lost on this.

http://twewy-fan.com/ <-- The first ever fansite for "The World Ends With You"
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 24th Feb 2009 23:18 Edited at: 24th Feb 2009 23:18
<return type> <function name>(<parameter list> )
{
<code>
return <result>;
}

eg:
bool isgreater(int a, int b)
{
bool result = a > b;
return result;
}

[b]Yuor signutare was aresed by a deslyxic mud...
BOX2D V2 HAS HELP FILES! AND A WIKI!
Cuddle Bunniezzz 12
15
Years of Service
User Offline
Joined: 14th Jan 2009
Location: Buffalo, NY
Posted: 25th Feb 2009 01:52
Do I shove in functions before the end of the DarkGDK function?

http://twewy-fan.com/ <-- The first ever fansite for "The World Ends With You"
Bran flakes91093
16
Years of Service
User Offline
Joined: 13th Sep 2008
Location: Crazy Land
Posted: 25th Feb 2009 02:45 Edited at: 25th Feb 2009 02:49
Here, read this, it's great stuff.
http://www.cplusplus.com/doc/tutorial/functions.html
and
http://www.cplusplus.com/doc/tutorial/functions2.html

And, no...

You can't put functions in a function. (void DarkGDK(void) is a function)

Here's a DarkGDK example.


I'd really read the tutorials at http://www.cplusplus.com/doc/tutorial/ because they are great tutorials and you can learn a lot from them if you don't know how to do something.

EDIT: Sorry about that AndrewT, you were only about 20 seconds after!

#ifdef _DEBUG
FixBugs(All);
#endif
AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 25th Feb 2009 02:45 Edited at: 25th Feb 2009 02:47
Cuddle Bunniezzz: No, functions are defined outside your 'void DarkGDK( void )' function. It doesn't matter if they go above it or below it; however, if they go below it you need to declare the functions above it so you can still call them. So this:



is fine. However this:



Is not, because the function has not been declared yet when you're calling it. If you want to place your functions at the bottom of your code you must declare them before use like so:



EDIT: Ahhhhhh! Ninja'ed by Bran flakes...

Cuddle Bunniezzz 12
15
Years of Service
User Offline
Joined: 14th Jan 2009
Location: Buffalo, NY
Posted: 25th Feb 2009 03:46
Thank you.

http://twewy-fan.com/ <-- The first ever fansite for "The World Ends With You"

Login to post a reply

Server time is: 2024-09-30 19:29:31
Your offset time is: 2024-09-30 19:29:31