摘要:
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 阅读全文
摘要:
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 阅读全文