views:

25

answers:

0

Hi all,

I'm attempting to define the power operator ** in a C# class (we'll call it class Foo). I've overridden __pow__(), which gets me the desired behavior for operations of type Foo ** int. Unfortunately, I need to also define int ** Foo, and neither using dynamic values nor overloading __pow__() gives me the desired behavior; I always receive the error unsupported operand type(s) for **: 'int' and 'Foo'. I have successfully overridden C#-recognized operators using the operator keyword; both Foo / int and int / Foo are functioning successfully. Is there any way to do this with __pow__()? Thank you in advance.