language: C++ 4.7.2 (gcc-4.7.2)
date: 332 days 13 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include<iostream>
 
using namespace std;
 
struct Add
{
template <typename A, typename B> A operator()(const A& lhs , const B& rhs)
{ return lhs+rhs; }
};
 
//some other ops
 
template <typename op, class A, class B >
A operate(A Fnum, B Snum){
op oper;
return oper(Fnum, Snum);
}
 
int main(){
int a = 20, b= 30;
std::cout<< operate<Add>(a,b)<<std::endl;
}