Passing operator as a parameter

Posted by nacho4d on Stack Overflow See other posts from Stack Overflow or by nacho4d
Published on 2010-12-25T15:06:43Z Indexed on 2010/12/25 15:54 UTC
Read the original article Hit count: 199

Filed under:
|
|
|

Hi,

I want to have a function that evaluates 2 bool vars (like a truth table)

for example:

since

T | F : T

then

myfunc('t', 'f', ||);  /*defined as: bool myfunc(char lv, char rv, ????)*/

should return true;

how can I pass the third parameter? (I know is possible to pass it as a char* but then I will have to have another table to compare operator string and then do the operation which is something I would like to avoid)

Is it possible to pass an operator like ^(XOR) or ||(OR) or &&(AND), etc in a function/method?

Thanks in advance

© Stack Overflow or respective owner

Related posts about c++

Related posts about c