[Gambas-user] Question about classes abd class variables

nando nando_f at ...951...
Sun Jul 17 05:07:07 CEST 2011


Benoit,

I'm look for clarity on a particular thing.

Consider the following example class named 'K':

    STATIC PUBLIC GridX AS Integer
    PUBLIC c AS Integer = 0

    PUBLIC SUB clear()
      c = 0
    END


The following two lines are in _init of another class or module:

  K.GridX = 6   <---This runs
  K.c = 1       <---This cause run-time error
  

My Question is this:

Anything declared class static automatically exists
before any NEW instances of it are created.

Which means I could consider them as Globals for any number of instances
of that class including *zero* instances of it.

Correct ??
-Fernando







More information about the User mailing list