lundi 2 mai 2016

Sending an operator as a paramenter in C++

I have two variables and an operator (could be any of +, - , /, comparison...). Is it a good idea to write a function that takes 2 arguments and the operator as the parameters?

Function may be something like below

T foo(int a,int b, sometype(not sure) operator)

and then make a string out of that

foo(a,b,+);

as  a+b

Would this be a good approach or is there any other approach?

Aucun commentaire:

Enregistrer un commentaire