static?

BlitzMax Forums/BlitzMax Programming/static?

I'm learning Blitz Max and C++ kind of at the same time. I was wondering if there is a equivalent statement for static in c++ to Blitz Max. This is the static that can be used in classes in C++.

i read somewhere that putting a global in a type is a static variable

Yea, use Global.

sweet!

You can also use Global as a static variable in a function.

Function IncAndPrint()
Global static_var = 10
static_var :+ 1
Print static_var
End Function

IncAndPrint()
IncAndPrint()
IncAndPrint()

End


if you use global in a Function / Method there are actually 2 different possibilities:

Static or Const

If you have global varname = XXX in a line it will end up as const at least on object. The new will not be reexecuted.
If you want the newe to be reexecuted, use global var and the initialization in a different line