摘要: 函数模板特化必须在实例化之前。成员模板函数(MTF)的特化必须在类外,不能使用内联(inline)进行特化。浮点数、类对象(class-type)、内部链接对象(如字符串常量"Hello World",注意:extern char const s[] = "hello"外部链接对象则可以)和全局指针... 阅读全文
posted @ 2015-04-22 23:10 motein 阅读(288) 评论(0) 推荐(0) 编辑
摘要: function3.h中的代码:#ifndef FUNCTION3_H#define FUNCTION3_H#include #include #include template T myMax(const T p1, const T p2){ std::cout int myMax(int ... 阅读全文
posted @ 2015-04-22 22:50 motein 阅读(320) 评论(0) 推荐(0) 编辑
摘要: 函数的定义function2.h:#ifndef FUNCTION2_H#define FUNCTION2_H#include #include #include template T myMax(const T p1, const T p2){ std::cout const char* m... 阅读全文
posted @ 2015-04-22 22:26 motein 阅读(243) 评论(0) 推荐(0) 编辑
摘要: 模板函数定义文件function1.h:#ifndef FUNCTION1_H#define FUNCTION1_H#include #include template inline T const& max(T const&a , T const& b){ return a inline T... 阅读全文
posted @ 2015-04-22 22:03 motein 阅读(181) 评论(0) 推荐(0) 编辑
摘要: Stack4.hpp的代码如下:#ifndef STACK4_HPP#define STACK4_HPP#include #include #include template class Stack{public: Stack(); void push(T const&); voi... 阅读全文
posted @ 2015-04-22 00:55 motein 阅读(155) 评论(0) 推荐(0) 编辑
摘要: Stack3.h的内容如下:#ifndef STACK3_H#define STACK3_H#include #include #include template >class Stack{private: CONT elems;public: void push(T const&);... 阅读全文
posted @ 2015-04-22 00:22 motein 阅读(187) 评论(0) 推荐(0) 编辑
摘要: MyClass.h文件代码:#ifndef MYCLASS_H#define MYCLASS_H#includetemplate class MyClass{public: void print() { std::cout class MyClass{public: ... 阅读全文
posted @ 2015-04-22 00:04 motein 阅读(226) 评论(0) 推荐(0) 编辑