Skip to content

4. Variables Declaration

Nicolas BOITEUX edited this page Nov 5, 2017 · 15 revisions

To declare a variable you have to use a syntax like this:

_VISIBILITY_ VARIABLE("_TYPE_","_NAME_");

_VISIBILITY_

  • PRIVATE Initializes a private member within a class. Private members may only be accessed by members of its own class.
  • PROTECTED Initializes a protected member within a class. Protected members may only be accessed by members of its own class or child classes.
  • PUBLIC Initializes a public member within a class. Public members may be accessed by anyone.

_TYPE_

You have to choose your variable type according your need. Type should be a type equivalent of the return of typename command like:

  • ARRAY

  • STRING

  • SCALAR for numbers

  • CODE for other OOP object

  • OBJECT for arma object

_NAME_

The name of your variable.

Examples

PUBLIC VARIABLE("object","foo");
PUBLIC VARIABLE("string","foo");
PUBLIC VARIABLE("scalar","foo");
PUBLIC VARIABLE("code","foo");
PUBLIC VARIABLE("array","foo");

PRIVATE VARIABLE("object","foo");
PRIVATE VARIABLE("string","foo");
PRIVATE VARIABLE("scalar","foo");
PRIVATE VARIABLE("code","foo");
PRIVATE VARIABLE("array","foo");

INITIALIZATION

It's particulary recommanded to initialize all your object variables during the construction of the object through the constructor method, and to reduce the visibility of them with PRIVATE visibility.

Clone this wiki locally