#include "stdafx.h"
#include <iostream>
using namespace std;
template <typename T>
class plus
{
public:
T operator()(const T& x, const T& y) const
{
return (x + y);
}
};
template <typename T>
class minus
{
public:
T operator()(const T& x, const T& y) const
{
return (x - y);
}
};
int main(int argc, char* argv[])
{
plus<int> plusobj;
minus<int> minusobj;
cout << plusobj(3, 5) << endl;
cout << minusobj(3, 5) << endl;
cout << plus<int>() (43, 50) << endl;
cout << minus<int>() (43, 50) << endl;
return 0;
}
本文地址:http://com.8s8s.com/it/it22233.htm