piece of code(2)

based on <STL源码剖析>


#include <iostream>



using namespace std;


template <class T>
struct pluS{
public:
        T operator()(const T& x, const T& y)const {return x+y;}
};


template <class T>
struct minuS{
public:
        T operator()(const T&x, const T& y)const {return x-y;}
};


int main()
{
        pluS<int> plusobj;
        minuS<int> minusobj;


        cout << plusobj(7, 8) << endl;
        cout << minusobj(100, 200) << endl;


        cout << pluS<int>()(70, 80)<< endl;
        cout << minuS<int>()(200, 100)<<endl;
        return 0;
}

你可能感兴趣的:(piece of code(2))