L
leriaat
I would like to create a calculator, and I thought that it would be a
good idea to write a universal "do_it" function that would have a
pointer to the operator and the two operands like this:
double do_it(double a, doulbe b, doulbe (*op)(doulbe, doulbe) ) {
return op(a, b); }
Well, the idea is great, but I don't know how could I put a pointer to
the + operator... Is it possible at all? I mean something like this:
cout << do_it(1, 2, &(operator+) );
good idea to write a universal "do_it" function that would have a
pointer to the operator and the two operands like this:
double do_it(double a, doulbe b, doulbe (*op)(doulbe, doulbe) ) {
return op(a, b); }
Well, the idea is great, but I don't know how could I put a pointer to
the + operator... Is it possible at all? I mean something like this:
cout << do_it(1, 2, &(operator+) );