12 2016 档案

摘要:#include #include struct cmp_str{ bool operator()(char const* a, char const* b){ return std::strcmp(a, b) v;//此时比较的是指针的值,今天差点这样用,如果这样需要自己写比较器 const char* a = "bello"; const cha... 阅读全文
posted @ 2016-12-05 23:58 zzyoucan 阅读(5751) 评论(0) 推荐(0) 编辑
摘要://类成员函数模板特化 #include class A{ public: template void Print(){ printf("A template\n"); } }; template void A::Print(){ printf("int\n"); } int main(){ A a; a.Print(); ... 阅读全文
posted @ 2016-12-03 21:19 zzyoucan 阅读(412) 评论(0) 推荐(0) 编辑
摘要:#include template T max(T x, T y) { return x > y ? x : y; } //函数模板特化 template const char* max(const char* x, const char* y){ return strcmp(x, y) > 0 ? x : y; } int main(){ std::cout ... 阅读全文
posted @ 2016-12-03 21:11 zzyoucan 阅读(1217) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示