- 博客(5)
- 收藏
- 关注
原创 模板的局限性和解决方法(具体化)
#include<iostream>#include<string>using namespace std;class Person{public: Person(string name,int age) { this->name=name; this->age=age; } string name; int age; ...
2019-09-29 01:47:28
234
原创 模板机制
1.程序的编译过程预处理(Pre-processing)->编译(Compiling)->汇编(Assembling)->链接(Linking)例: hello.c 经过预处理hello.i (将宏展开) hello.i经过编译器hello.s hello.s经过汇编器hello.o hello.o经过链接器hello.exe2.函数模板机制结论1....
2019-09-29 01:25:22
267
原创 普通函数和函数模板的调用规则
1.如果普通函数和函数模板可以同时使用,则优先调用普通函数2.如果想强制调用函数模板中的内容,可以使用空参数列表3.函数模板可以发生函数重载4.如果函数模板可以产生更好的匹配,那么优先使用函数模板#include<iostream>using namespace std;void func(int a,int b){ cout<<"普通函数调用"<&l...
2019-09-29 01:06:32
401
原创 用函数模板实现对int和char类型的数组进行排序
练习#include<iostream>using namespace std;template<typename T>void mySwap(T &a,T &b){ T temp=a; a=b; b=temp;}//选择排序template<typename T>void mySort(T arr[],int len)...
2019-09-29 00:47:00
708
原创 函数模板
函数模板1.函数模板的写法#include<iostream>using namespace std;void mySwapInt(int &a,int &b){ int temp=a; a=b; b=temp;}void mySwapDouble(double &a,double &b){ double temp=a; a=...
2019-09-29 00:20:45
116
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人