assigning math operators to objects
I was wondering if there is any way to assign math operators to objects class that I constructed?
or to construct a math operation from objects. I am coding a Form app that does some pretty complex math and there are visual representations of the math operators for the user to manipulate and create complex math operations with. effectively, I want to have objects that have a complex math operator such as "-(NOT or Negative)" "~ (OR)" ". (AND)" "> (THEN, or IF/Then)".
Re: assigning math operators to objects
Do you think something like this?
Code:
public class Foo
{
public int v;
public static Foo operator +(Foo a, Foo b) {
return new Foo { v = a.v + b.v };
}
}
But I'm not sure if all operators can be defined this way, It seems that only existing binary operators can.