Is there anyway I can achieve make an operator (eg +) for a struct I've defined myself. For example:
Code:
typedef struct complex {
double a;
double b;
};
main(){
struct complex foo,bar,foobar;
foo.a = 4; foo.b = 7; //foo = 4 + 7j
bar.a = -3; bar.b = 2; //bar = 2j - 3
foobar = foo+bar; //foobar = 1 + 9j
}
I know that it can be done in C++, but I don't fancy learning the whole classes making thing just for this.
Thank you.
EDIT: Also, if there a clever way to set a struct, like foo = {4,5}; instead of invidually setting both members. I tried the above, but DJGPP didn't like it when not used during the original creation (struct complex foo = {4,7}; ).