Originally Posted by
itCbitC
Just like you would declare an array of ints for ex. except that each element is of the type struct instead of an int.
Ok say I have this struct..
Code:
typedef struct Operator
{
char symbol;
int operands;
union
{
void *f;
double (*f0)(void);
double (*f1) (double x);
double (*f2) (double x, double y);
}
}Operator;
Operator mult={'*',2,multiply1};
Operator add={'+',2,add1};
Operator neg={'-',1,neg1};
Operator divide={'/',2,divide1};
Operator square={'sq',1,square1};
Operator sqrt={'sqrt',1,squareRoot1};
Operator min={'m',2,min1};
Operator max={'M',2,max1};
Operator expo={'^',2,expo1};
Operator pi={'pi',0,pi};
Operator loga={'log',1,L};
Operator expon={'e^',1,E};
So would it be like this?:
Code:
double main (void)
{
Operator op[12]={mult, add, neg};
}
etc... ?