摘要: template class SmartPtr { T* m_p; public: SmartPtr(T* p) : m_p(p) {} T* operator->() { return m_p; } } class XxX { public: void foo(); } int main() { Xxx x; ... 阅读全文
posted @ 2008-03-26 22:02 悠然小调 阅读(502) 评论(0) 推荐(0) 编辑
摘要: 一。函数模板的特化 考虑: template T max(T a, T b) { return a > b ? a : b; } int main() { cout char* max(char* a, char* b) { return strlen(a) > strlen(b) ? a : b; } 二。类模板的特化 template class Test { ... 阅读全文
posted @ 2008-03-26 21:51 悠然小调 阅读(332) 评论(0) 推荐(0) 编辑
摘要: class Base1 { public: virtual void foo(); }; class Base2 { public: virtual void foo(); }; class Derived : public Base1, public Base2 { public: virtual void foo(); }; #define SOMETHING... 阅读全文
posted @ 2008-03-26 21:09 悠然小调 阅读(423) 评论(0) 推荐(0) 编辑