What's the difference between static and new?
#8

Quote:
Originally Posted by Mencent
Посмотреть сообщение
Bullshit...

If he don't know the difference between "new" and "static" he ask. So, he did it.

The difference between "static" and "new" is, that the declaration of "static" can used also in filterscripts, includes and gamemodes at the same time.. The declaration of "new" can't used in filterscripts, includes and gamemodes at the same time.


- Mencent
Okay, but that's not what I said. I said if you don't know what the difference is, don't use it. Also, 'new' can be used in filterscripts, includes and gamemodes at the same time as well? How is that a 'difference'?

Static variables remember their old values, and can only be used in the script in which they're declared.

Quote:
Originally Posted by Sjn
Посмотреть сообщение
Oh ok, but 1 more question. I have an include called def.inc which has all of my arrays, enums, defines and other vars stored. If i create a connection handle for mysql in that include with static, it gives undefined symbol error, but if i create it with new, it works fine. Why is that?
Because 'static' variables only exist within the script they are declared in. So if you put it in your include file, the variables will not work outside of that include file.
Reply


Messages In This Thread
What's the difference between static and new? - by Sjn - 20.07.2015, 10:54
Re: What's the difference between static and new? - by xVIP3Rx - 20.07.2015, 10:58
Re: What's the difference between static and new? - by Threshold - 20.07.2015, 11:28
AW: Re: What's the difference between static and new? - by Mencent - 20.07.2015, 11:32
AW: What's the difference between static and new? - by Kaliber - 20.07.2015, 11:40
Re: What's the difference between static and new? - by Sjn - 20.07.2015, 11:45
AW: What's the difference between static and new? - by Kaliber - 20.07.2015, 11:47
Re: AW: Re: What's the difference between static and new? - by Threshold - 20.07.2015, 16:28

Forum Jump:


Users browsing this thread: 1 Guest(s)