为什么需要类模板 类模板与函数模板的定义和使用类似,有时,有两个或多个类,其功能是相同的,仅仅是数据类型不同,我们可以通过如下面语句声明了一个类模板: #include <iostream> #include <Windows.h> using namespace std; template <typename T> class A