C++ template
文章平均质量分 80
sohochaser
这个作者很懒,什么都没留下…
展开
-
C++ template - 类模板
//类模板 Stack 类为例//1. 使用该类的类型时,用Stack//2. 使用类名而不是类的类型时,用Stacktemplate class Test{private: T a[MAXSIZE];public: Test(){}};原创 2009-06-11 13:32:00 · 696 阅读 · 0 评论 -
C++ template -- 实践1
1. 例子//myfirst.htemplate void print_typeof (T const&); //myfirst.cpp#include #include #include "myfirst.hpp"// implementation/definition of templatetemplate void print_typeof (T const&原创 2009-06-11 18:12:00 · 429 阅读 · 0 评论 -
c++ template - 模板函数 1
// 模版编译// 1.实例化前,语法检查!// 2.实例化时,检查模版代码,是否调用有效,如某些实例化类型不支持某些函数调用!// 有模版函数与非模板函数,共存时,优先调用非模板函数!// - - - - - - - - - - - -- - -- - - - - - - - - return type ... template inline RT max(T1 const& a,原创 2009-06-11 13:30:00 · 369 阅读 · 0 评论 -
c++ template - 成员模板
1.1.1 .templates构造这个比较生僻一些,给个例子吧templatevoid printBitset(std::bitset const& bs){ std::cout, std::allocator >();}//传入参数bs依赖模板参数的构造1.3 成员模板类成员也可以是模板,嵌套类和成员函数都可以作为模板。下面通过Stacktemp原创 2009-06-11 16:49:00 · 632 阅读 · 0 评论 -
C++ template - 模板的模板参数
//stack8.hpp#include #include #include template template typename = std::allocator > class CONT = std::deque>class Stack { private: CONT elems;原创 2009-06-11 17:00:00 · 695 阅读 · 0 评论 -
C++ template -- 字符串作为函数模板实参
1.#include // note: reference parameterstemplate inline T const& max (T const& a, T const& b){ return a }int main(){ std::string s; ::max("apple","peach"); // OK: same type ::ma原创 2009-06-11 17:31:00 · 1269 阅读 · 0 评论 -
STL 错误信息解释器 (STL Error Message Decryptor for C++ )
http://www.bdsoft.com/tools/stlfilt.html 这个工具不错,可以对STL出错信息进行过滤处理,让信息容易看懂! Linux 用法:1. 下载 gstlfilt.tar 2. gfilt g++ test.cpp ...STLFilt:An STL Error Message Decryptor for C++ Open原创 2009-06-15 18:32:00 · 1009 阅读 · 0 评论