| AngelScript |

Const methods

Classes add a new type of function overload, i.e. const overload. When a class method is accessed through a read-only reference or handle, only methods that have been marked as constant can be invoked. When the reference or handle is writable, then both types can be invoked, with the preference being the non-const version in case both matches.

      class CMyClass
      {
        int method()       { a++; return a; }
        int method() const {      return a; }
        int a;
      }
      void Function()
      {
         CMyClass o;
         const CMyClass @h = o;

         o.method(); // invokes the non-const version that increments the member a
         h.method(); // invokes the const version that doesn't increment the member a
      }