2005/5/10

     
 

CfgScript Class Members

artefaktur

| ClassDeclaration | Class Methods | Class Members | Calling Interface |

Class members are static or non static data fields of a class


Content of this chapter:

   ClassMembers


 ClassMembers

ClassMembers
: ( ClassMemberAttribute )* TypeName Identifier [ '=' Expression ] ';'
;


ClassMemberAttribute
: 'public'
| 'protected'
| 'private'
| 'static'
;

static members can be accessed without an object instance.

class MyClass
{
  // non-static variable, uninitialized, may be initialized in Constructor
  int ivar; 
  
  // non-static variable, initialized
  bool isValid = true; 
  
  // static class Variable, initialized with an value
  static acdk.lang.String staticString = "init-Value"; 
  
  // constructor
  MyClass()
  {
    ivar = 42;
    // isValid is already initialized
  }
}

// can be accessed through class name
acdk.lang.String s = MyClass.staticString;

MyClass myclass = new MyClass();
int i = myclass.ivar;


public, protected, private are currently not supported.