fork download
  1. #include<iostream>
  2.  
  3. using namespace std;
  4.  
  5. struct Add
  6. {
  7. template <typename A, typename B> A operator()(const A& lhs , const B& rhs)
  8. { return lhs+rhs; }
  9. };
  10.  
  11. //some other ops
  12.  
  13. template <typename op, class A, class B >
  14. A operate(A Fnum, B Snum){
  15. op oper;
  16. return oper(Fnum, Snum);
  17. }
  18.  
  19. int main(){
  20. int a = 20, b= 30;
  21. std::cout<< operate<Add>(a,b)<<std::endl;
  22. }
  23.  
Success #stdin #stdout 0.01s 2724KB
stdin
Standard input is empty
stdout
50