- #1
Jamin2112
- 986
- 12
I was looking at an example from here: http://cboard.cprogramming.com/cplusplus-programming/133294-passing-operator-parameter.html
I'm confused about what it means to pass "Or()" into the function. "Or" is a type of struct and he's passing it in what an empty parantheses. Not sure how that has any meaning.
Code:
template <class T> bool myfunc(bool lv, bool rv, T oper)
{
return oper(lv, rv);
}
struct Or
{
bool operator()(bool lv, bool rv)
{
return lv || rv;
}
};
int main()
{
bool result = myfunc(true, false, Or());
return 0;
}
I'm confused about what it means to pass "Or()" into the function. "Or" is a type of struct and he's passing it in what an empty parantheses. Not sure how that has any meaning.