模板就是C++泛型编程的内容,主要是为了更好的泛化
template <typename T>
这里的T就是一个还未定义的类型名:该类型名可以自动推导,也可以显示指定类型。
除了使用typename
还可以用class
#include <iostream>
#include <string>
using namespace std;
//面
模板就是C++泛型编程的内容,主要是为了更好的泛化
template <typename T>
这里的T就是一个还未定义的类型名:该类型名可以自动推导,也可以显示指定类型。
除了使用typename
还可以用class
#include <iostream>
#include <string>
using namespace std;
//面