Method

Operator_Power


Description

Used to overload the ^ operator, providing custom functionality.

Notes

Create an Operator_Power function in a class to specify the functionality of the ^ operator for that class. When you use the ^ operator in your code to operate on two instances of the class, your Operator_Power function will be called.

In the function, the Self instance the left operand and the other operand is passed as a parameter. The Self instance is raised to the power specified by the passed instance.

Sample code

Using the Vector class (see Operator Add) with two Integer elements, x and y, we define an Operator_Power function that raises the sum of the Self instance to the power of the passed instance.

Function Operator_Power(rhs As Vector) As Integer
  Var a, b As Integer
  a = Self.x + Self.y
  b = rhs.x + rhs.y

  Return a ^ b
End Function

Compatibility

All project types on all supported operating systems.

See also

^ operator; Operator PowerRight function.