上一页 1 ··· 79 80 81 82 83 84 85 86 87 ··· 92 下一页
摘要: #include<iostream> #include<stdlib.h> #include<string> using namespace std; #include<typeinfo> /* 1.3.6类模板成员函数类外实现 */ template<class T1, class T2> cla 阅读全文
posted @ 2021-04-18 14:12 yub4by 阅读(64) 评论(0) 推荐(0)
摘要: #include<iostream> #include<stdlib.h> #include<string> using namespace std; #include<typeinfo> /* 1.3.5类模板与继承 当子类继承的父类是一个类模板时,子类在声明的时候,要指定出父类中T的类型 如果不 阅读全文
posted @ 2021-04-18 14:11 yub4by 阅读(93) 评论(0) 推荐(0)
摘要: #include<iostream> #include<stdlib.h> #include<string> using namespace std; #include<typeinfo> /* 1.3.4类模板对象做函数参数 类模板实例化出的对象,向函数传参的方式 共有三种传入方式: 1. 指定传 阅读全文
posted @ 2021-04-18 11:19 yub4by 阅读(67) 评论(0) 推荐(0)
摘要: #include<iostream> #include<stdlib.h> #include<string> using namespace std; /* 1.3.3类模板中成员函数创建时机 类模板中成员函数和普通类中成员函数创建时机是有区别的: 普通类中的成员函数一开始就可以创建 类模板中的成员 阅读全文
posted @ 2021-04-17 21:19 yub4by 阅读(73) 评论(0) 推荐(0)
摘要: #include<iostream> #include<stdlib.h> #include<string> using namespace std; /* 1.3.2类模板和模板函数的区别 1. 类模板没有自动类型推导的使用方式 2. 类模板在模板参数列表中可以有默认参数(函数模板不可以有默认) 阅读全文
posted @ 2021-04-17 21:18 yub4by 阅读(90) 评论(0) 推荐(0)
摘要: #include<iostream> #include<stdlib.h> #include<string> using namespace std; /* 1.3类模板 1.3.1类模板语法 作用:建立一个通用类,类中的成员 数据类型可以不具体制定,用一个虚拟的类型来代表 语法:template< 阅读全文
posted @ 2021-04-17 20:09 yub4by 阅读(72) 评论(0) 推荐(0)
摘要: #include<iostream> #include<stdlib.h> #include<string> using namespace std; /* 1.2.6模板的局限性 模板的通用性并不是万能的 */ // **************************************** 阅读全文
posted @ 2021-04-17 20:08 yub4by 阅读(64) 评论(0) 推荐(0)
摘要: #include<iostream> #include<stdlib.h> #include<string> using namespace std; /* 1.2.5普通函数和函数模板的调用规则 1. 如果函数模板和普通函数都可以实现,优先调用普通函数 2. 可以通过空模板参数列表来强制调用函数模 阅读全文
posted @ 2021-04-17 20:07 yub4by 阅读(57) 评论(0) 推荐(0)
摘要: #include<iostream> #include<stdlib.h> #include<string> using namespace std; /* 1.2.4 普通函数和函数模板的区别 普通函数调用时可以发生自动类型转换(隐式类型转换) 函数模板调用时,如果利用自动类型推导,不会发生隐式类 阅读全文
posted @ 2021-04-17 20:06 yub4by 阅读(53) 评论(0) 推荐(0)
摘要: #include<iostream> #include<stdlib.h> #include<string> using namespace std; /* 1.2.3函数模板案例 利用函数模板封装一个排序的函数,可以对不同数据类型数组进行排序 排序规则从大到小,排序算法为选择排序 */ templ 阅读全文
posted @ 2021-04-17 20:05 yub4by 阅读(58) 评论(0) 推荐(0)
上一页 1 ··· 79 80 81 82 83 84 85 86 87 ··· 92 下一页