摘要: 一、为了保证T::const_iterator不被看作类的成员变量,使用typename修饰表明它是模板类里的类型。 #include <iostream> #include <vector> template<typename T> void printcoll(T const& coll) { 阅读全文
posted @ 2020-05-27 15:54 习惯就好233 阅读(213) 评论(0) 推荐(0) 编辑
摘要: 第四章: 一、非类型的类模板参数 template不仅可以使用参数typename,一般的参数也是可以用的。这里定义了最大数组。 #pragma once #include <stdexcept> template<typename T, int MAXSIZE> class Stack { pri 阅读全文
posted @ 2020-05-27 13:40 习惯就好233 阅读(477) 评论(0) 推荐(0) 编辑