|
-
November 17th, 2010, 12:29 PM
#1
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)".
-
November 23rd, 2010, 09:21 AM
#2
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.
- Make it run.
- Make it right.
- Make it fast.
Don't hesitate to rate my post. 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|