AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Difference between static and new. (https://forums.alliedmods.net/showthread.php?t=107303)

unnyquee 10-25-2009 04:52

Difference between static and new.
 
What is the difference between 'static' and 'new' when it comes to strings?
When I should use 'static', when 'new' ?

-Thx in advance :)

ConnorMcLeod 10-25-2009 04:54

Re: Difference between static and new.
 
There is a snippet by Hawk552 about this.

SnoW 10-25-2009 04:59

Re: Difference between static and new.
 
Quote:

Originally Posted by ConnorMcLeod (Post 971496)
There is a snippet by Hawk552 about this.

Wouldn't trust that, since he wasn't ready to debate or even answer to one post to prove himself right.
http://forums.alliedmods.net/showthr...=106358&page=5

unnyquee 10-25-2009 05:58

Re: Difference between static and new.
 
So kinda like..
It's more readable and kind of well-coded using (for arrays):
PHP Code:

static szMessage[64]; 

Instead of:
PHP Code:

new szMessage[64]; 

Or am I wrong?

Arkshine 10-25-2009 06:15

Re: Difference between static and new.
 
No no.

Using static means the memory is created one time so the var is not initialized each time. It's like a global var but restricted to the function. You can see an example there.

unnyquee 10-25-2009 06:26

Re: Difference between static and new.
 
I get it!
Thx Arkshine, +k!


All times are GMT -4. The time now is 17:32.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.