摘要:
stl中的仿函数functor的应用在stl的泛型算法中,functor应用甚多。template <typename T>struct plus{ T operator ()(const T& x, const T& y) { return x + y; }};template <typename T>struct minus{ T operator ()(const T& x, const T& y) { return x - y; }};void test(){ plus<int> plusObj; minus<i 阅读全文
posted @ 2011-10-03 21:36
SunWentao
阅读(940)
评论(0)
推荐(0)
摘要:
atl/wtl中运用的非虚函数多态template <typename T>class B1{public: void SayHi() { T *pT = static_cast<T*>(this); pT->PrintClassName(); }protected: void PrintClassName() { cout << "B1" << endl; }};class D1 : public B1<D1>{ // no overridden function at all};class D2 : pu 阅读全文
posted @ 2011-10-03 14:25
SunWentao
阅读(454)
评论(0)
推荐(0)
浙公网安备 33010602011771号