View previous topic :: View next topic |
Author |
Message |
lucid Master Cheater Reputation: 0
Joined: 23 Jan 2008 Posts: 424
|
Posted: Mon Oct 25, 2010 2:15 pm Post subject: C++ Functions |
|
|
I don't get them :\
Anyone have a good example of why -and/or- how they are useful?
|
|
Back to top |
|
|
Cheat Engine User Something epic Reputation: 60
Joined: 22 Jun 2007 Posts: 2071
|
Posted: Mon Oct 25, 2010 2:21 pm Post subject: |
|
|
There are no c++ functions. Simple as that.
|
|
Back to top |
|
|
Benji Random spam moderator Reputation: 3
Joined: 31 Dec 2007 Posts: 58 Location: The Netherlands
|
Posted: Mon Oct 25, 2010 2:25 pm Post subject: |
|
|
I don't know how to use functions in C++, but I do know function usage in general.
Code: |
new function charJump {
(code of your game character jumping comes here)
}
if key.up = true {
function charJump;
} |
A.K.A, you can use large blocks of code with just 1 simple command.
_________________
|
|
Back to top |
|
|
shitposter Newbie cheater Reputation: 5
Joined: 12 Nov 2008 Posts: 13
|
Posted: Mon Oct 25, 2010 2:32 pm Post subject: |
|
|
I forgot all the C++ I knew.
I only know Lua now.
|
|
Back to top |
|
|
lucid Master Cheater Reputation: 0
Joined: 23 Jan 2008 Posts: 424
|
Posted: Mon Oct 25, 2010 4:09 pm Post subject: |
|
|
Quote: | Functions that a programmer writes will generally require a prototype. Just like a blueprint, the prototype tells the compiler what the function will return, what the function will be called, as well as what arguments the function can be passed. When I say that the function returns a value, I mean that the function can be used in the same manner as a variable would be. For example, a variable can be set equal to a function that returns a value between zero and four. |
Now explain this shite
My brain doesn't grasp what it cannot comprehend. So make it dumb.
|
|
Back to top |
|
|
Monkeys I post too much Reputation: 29
Joined: 20 Jul 2006 Posts: 2411
|
Posted: Mon Oct 25, 2010 4:16 pm Post subject: |
|
|
Yes.
_________________
Get a lid on that zombie,
he's never gonna be alri-i-ight.
Oooh get a lid on that zombie,
or he's gonna feed all night. |
|
Back to top |
|
|
Noz3001 I'm a spammer Reputation: 26
Joined: 29 May 2006 Posts: 6220 Location: /dev/null
|
Posted: Mon Oct 25, 2010 4:16 pm Post subject: |
|
|
prototype:
Code: | int fuckingDicks(int, float, double, char); |
function:
Code: | int fuckingDicks(int x, float shit, double cock, char p) {
return x+69;
} |
|
|
Back to top |
|
|
Gavin Moderator Reputation: 114
Joined: 30 Apr 2007 Posts: 1069
|
Posted: Mon Oct 25, 2010 4:17 pm Post subject: |
|
|
What's on your mind Nathan?
|
|
Back to top |
|
|
lucid Master Cheater Reputation: 0
Joined: 23 Jan 2008 Posts: 424
|
Posted: Mon Oct 25, 2010 4:19 pm Post subject: |
|
|
theflyingwop wrote: | prototype:
Code: | int fuckingDicks(int, float, double, char); |
function:
Code: | int fuckingDicks(int x, float shit, double cock, char p) {
return x+69;
} |
|
Now why would I use this instead of a simpler code?
|
|
Back to top |
|
|
Monkeys I post too much Reputation: 29
Joined: 20 Jul 2006 Posts: 2411
|
Posted: Mon Oct 25, 2010 4:21 pm Post subject: |
|
|
Shigan wrote: | theflyingwop wrote: | prototype:
Code: | int fuckingDicks(int, float, double, char); |
function:
Code: | int fuckingDicks(int x, float shit, double cock, char p) {
return x+69;
} |
|
Now why would I use this instead of a simpler code? |
Say you have to use a certain snippet of code a lot.
Like creating a certain entity.
You'll write that snippet as a function and just call that function instead.
Like so:
Code: | main_playthrough()
{
CreateEntity("Darp");
CreateEntity("Varp");
}
void CreateEntity( Char[] )
{
// Create it here etc...
} |
_________________
Get a lid on that zombie,
he's never gonna be alri-i-ight.
Oooh get a lid on that zombie,
or he's gonna feed all night. |
|
Back to top |
|
|
lucid Master Cheater Reputation: 0
Joined: 23 Jan 2008 Posts: 424
|
Posted: Mon Oct 25, 2010 4:25 pm Post subject: |
|
|
Ohhhh
I get it. So if you had some simple code that did one thing, instead of writing it over 9000 times, you just call the function over 9000 times.
It's laziness, right? ( Also efficiency. )
|
|
Back to top |
|
|
Monkeys I post too much Reputation: 29
Joined: 20 Jul 2006 Posts: 2411
|
Posted: Mon Oct 25, 2010 4:26 pm Post subject: |
|
|
Shigan wrote: | Ohhhh
I get it. So if you had some simple code that did one thing, instead of writing it over 9000 times, you just call the function over 9000 times.
It's laziness, right? ( Also efficiency. ) |
The latter.
Instead of c&p'ing 200 lines of code each time you need the functionality, you simply call that one line prototyped function.
_________________
Get a lid on that zombie,
he's never gonna be alri-i-ight.
Oooh get a lid on that zombie,
or he's gonna feed all night. |
|
Back to top |
|
|
Noz3001 I'm a spammer Reputation: 26
Joined: 29 May 2006 Posts: 6220 Location: /dev/null
|
Posted: Mon Oct 25, 2010 4:26 pm Post subject: |
|
|
Shigan wrote: | Ohhhh
I get it. So if you had some simple code that did one thing, instead of writing it over 9000 times, you just call the function over 9000 times.
It's laziness, right? ( Also efficiency. ) |
Go read a programming book
|
|
Back to top |
|
|
lucid Master Cheater Reputation: 0
Joined: 23 Jan 2008 Posts: 424
|
Posted: Mon Oct 25, 2010 4:27 pm Post subject: |
|
|
Thank god. That makes my life much, much easier. Thanks Monkeys.
@guy above me: I am, derpslime.
|
|
Back to top |
|
|
shitposter Newbie cheater Reputation: 5
Joined: 12 Nov 2008 Posts: 13
|
Posted: Mon Oct 25, 2010 4:28 pm Post subject: |
|
|
Any decent documentation would have told you all of this, either you're not paying attention or the doc is shit.
|
|
Back to top |
|
|
|