what is "static"? (question)
#4

Quote:
Originally Posted by okaym8
Посмотреть сообщение
Ahh, ok for example about static inside functions i do this:

Код:
stock function()
{
     static a =50;
     a++;
     print("%d", a);
}

function();
function();
it will add 1 to 50 and it becomes 51 and the number 51 will be kept as the new int for the value, right?

see i used "function();" two times, that means the first time it will return 50 + 1 = 51 and then, it will return the second time 52 because it kept "51" and it added 1 after
am i right?

and one little question, can we use static for strings?
thanks in advance
Yes you are right about the first question
And second yes you can use static for each type of variable you want to use BUT you have to be sure that the VARIABLE you want to change is the same type as the static variable(If i am not wrong!)
Reply


Messages In This Thread
what is "static"? (question) - by okaym8 - 26.11.2015, 10:31
Re: what is "static"? (question) - by Vince - 26.11.2015, 11:06
Re: what is "static"? (question) - by okaym8 - 26.11.2015, 15:24
Re: what is "static"? (question) - by vassilis - 26.11.2015, 15:33
Re: what is "static"? (question) - by okaym8 - 26.11.2015, 15:35

Forum Jump:


Users browsing this thread: 1 Guest(s)