This code expression<int, opAndNot> exp(f(a), g(b), opAndNot());
calls the return value of the function. So, the T& a; T& b;
should be modified to T a; T b;
.
Also, The reason for C2228 is just because the operand .exp
to the left of the period (.) is not a class, structure, or union. You could put it in if
or else
.
if (condA)
expression<int, opAndNot> exp(f(a), g(b), opAndNot());
int retVal = exp.eval();
else
expression<int, opOr> exp(f(a), g(b), opOr());