随笔分类 - 重学C++
摘要:#include<iostream> #include<stdlib.h> #include<string> using namespace std; /* 1.2.6模板的局限性 模板的通用性并不是万能的 */ // ****************************************
阅读全文
摘要:#include<iostream> #include<stdlib.h> #include<string> using namespace std; /* 1.2.5普通函数和函数模板的调用规则 1. 如果函数模板和普通函数都可以实现,优先调用普通函数 2. 可以通过空模板参数列表来强制调用函数模
阅读全文
摘要:#include<iostream> #include<stdlib.h> #include<string> using namespace std; /* 1.2.4 普通函数和函数模板的区别 普通函数调用时可以发生自动类型转换(隐式类型转换) 函数模板调用时,如果利用自动类型推导,不会发生隐式类
阅读全文
摘要:#include<iostream> #include<stdlib.h> #include<string> using namespace std; /* 1.2.3函数模板案例 利用函数模板封装一个排序的函数,可以对不同数据类型数组进行排序 排序规则从大到小,排序算法为选择排序 */ templ
阅读全文
摘要:#include<iostream> #include<stdlib.h> #include<string> using namespace std; /* 1.2.2函数模板注意事项 自动类型推导,必须推导出一致的数据类型T,才可以使用 模板必须要确定出T的数据类型,才可以使用 */ templa
阅读全文
摘要:#include<iostream> #include<stdlib.h> #include<string> using namespace std; /* 1.1模板概念 C++另一种编程思想称为 泛型编程 ,主要利用的技术就是模板 C++提供两种模板机制:函数模板和类模板 */ /* 1.2函数
阅读全文