上一页 1 ··· 17 18 19 20 21 22 23 24 25 ··· 32 下一页
  2021年8月13日
摘要: 1 //vector存放自定义数据类型 2 3 #include <iostream> 4 #include <string> 5 #include<fstream> 6 #include<vector> 7 #include<algorithm> 8 using namespace std; 9 阅读全文
posted @ 2021-08-13 17:20 Bytezero! 阅读(274) 评论(0) 推荐(0) 编辑
摘要: 1 //STL初始 2 // 3 //vector容器存放内置数组 4 5 #include <iostream> 6 #include <string> 7 #include<fstream> 8 using namespace std; 9 #include<vector> 10 #includ 阅读全文
posted @ 2021-08-13 15:12 Bytezero! 阅读(820) 评论(0) 推荐(0) 编辑
摘要: 1 //模板案例-数组封装类 2 //描述 3 //实现一个通用的数组类 4 //1.可以对内置数据类型以及自定义数据类型的数据进行储存 5 //2.将数组很脏的数据储存到堆区 6 //3.构造函数中可以传入数组的容量 7 //4.提供对应的拷贝构造函数以及operator=防止浅拷贝问题 8 // 阅读全文
posted @ 2021-08-13 13:52 Bytezero! 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 1 //类模板与友元 2 //全局函数类内实现 -直接在类内声名由于即可 3 //全局函数类外实现 -需要提前让编译器知道全局函数的存在 4 5 #include <iostream> 6 #include <string> 7 #include<fstream> 8 using namespace 阅读全文
posted @ 2021-08-13 10:40 Bytezero! 阅读(197) 评论(0) 推荐(0) 编辑
摘要: 1 //第一种方式被注释 2 //未被注释是第二种方式 3 //类模板分文件编写问题及解决 4 5 6 #include <iostream> 7 #include <string> 8 #include<fstream> 9 //第一中解决方式 直接包含源文件 10 //#include"pers 阅读全文
posted @ 2021-08-13 09:42 Bytezero! 阅读(125) 评论(0) 推荐(0) 编辑
摘要: 1 #include <iostream> 2 #include <string> 3 #include<fstream> 4 using namespace std; 5 6 template<class T1,class T2> 7 class Person 8 { 9 public: 10 / 阅读全文
posted @ 2021-08-13 09:38 Bytezero! 阅读(109) 评论(0) 推荐(0) 编辑
摘要: 1 #include <iostream> 2 #include <string> 3 #include<fstream> 4 using namespace std; 5 6 7 //类模板与继承 8 template<class T> 9 class Base 10 { 11 12 T m; 1 阅读全文
posted @ 2021-08-13 09:37 Bytezero! 阅读(73) 评论(0) 推荐(0) 编辑
摘要: 1 //类模板对象做函数参数 2 //三种方式 3 //1.指定传入的类型 --直接显示对象的数据类型 4 //2.参数模板化 --将对象中的参数变为模板进行传递 5 //3.整个类模板化 --将这个对象类型 模板化进行传递 6 7 8 #include <iostream> 9 #include 阅读全文
posted @ 2021-08-13 09:36 Bytezero! 阅读(87) 评论(0) 推荐(0) 编辑
摘要: 1 //类模板中成员函数创建时机 2 //类模板中成员函数和普通类中成员函数创建时机是有区别的: 3 //1.普通类中的成员函数一开始就可以创建 4 //2.类模板中的成员函数在调用时才创建 5 6 7 #include <iostream> 8 #include <string> 9 #inclu 阅读全文
posted @ 2021-08-13 09:34 Bytezero! 阅读(67) 评论(0) 推荐(0) 编辑
摘要: 1 //类模板与函数模板的区别 2 //1.类模板没有自动类型推导的使用方式 3 //2.类模板子模板参数中可以有默认参数 4 5 #include <iostream> 6 #include <string> 7 #include<fstream> 8 using namespace std; 9 阅读全文
posted @ 2021-08-13 07:14 Bytezero! 阅读(83) 评论(0) 推荐(0) 编辑
上一页 1 ··· 17 18 19 20 21 22 23 24 25 ··· 32 下一页