Static Variables
Declaration
static keyword before the data type.static int flag = 10;Initialization
Lifetime and Scope
Usage
Example
int Counter()
{
static int count;
count++;
if(count % 100 == 0) Print("Function Counter has been called ", count, " times");
return count;
}void OnStart()
{
int c = 345;
for(int i = 0; i < 1000; i++)
{
int c = Counter();
}
Print("c = ", c);
}
Related Concepts
Previous
arrow_back
Formal parameters