| AngelScript |

Loading...
Searching...
No Matches
Script class overview

With classes the script writer can declare new data types that hold groups of properties and methods to manipulate them.

Script classes are reference types, which means that multiple references or handles can be held for the same object instance. The classes uses automatic memory management so the object instances are only destroyed when the last reference to the instance is cleared.

      // The class declaration
      class MyClass
      {
        // A class method
        void DoSomething() {}

        // Class properties
        int a;
        int b;
      }

A class can implement specific methods to overload operators. This can simplify how the object instances are used in expressions, so that it is not necessary to explicitly name each function, e.g. the opAdd method translates to the + operator.

Another useful feature is the ability to implement property accessors, which can be used either to provide virtual properties, i.e. that look like properties but really aren't, or to implement specific routines that must be executed everytime a property is accessed.

A script class can also inherit from other classes, and implement interfaces.