从http://wtl.sourceforge.net/下载 WTL 9.0,或者点此链接下载:WTL90_4140_Final.zip,然后解压到你的VC目录下面,我的地址是:C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\WTL,你可...
经验:Traits classes 使得"类型相关信息"在编译期可用。它们以 templates 和 "templates 特化"完成实现
示例:
template
class deque{
public:
class iterator{
public:
typedef random_access_iterator_tag iterator_category;
};
};
//template
template
struct iterator_trai...
分类:
编程语言 时间:
2014-07-15 22:40:20
阅读次数:
372
1.virtual 函数版本
class GameCharacter{
public:
virtual int healthValue() const; //返回人物的健康指数, derived classes 可重新定义它
};
2.使用 non-virtual interface 手法,那是 Template Method 设计模式的一种特殊形式。
让客户通过 public non-virtual 成员函数间接调用 private virtual 函数
class GameCharacter{
pu...
分类:
编程语言 时间:
2014-07-15 22:36:18
阅读次数:
364
经验:请使用 member function templates(成员函数模板)生成"可接受所有兼容类型"的函数
示例:泛化 copy 构造函数
temmplate
class SmartPtr{
public:
template
SmartPtr(const SmartPtr &other) //member template, 为了生成 copy 构造函数
: heldPtr(other.get()){...}
T *get() const...
分类:
编程语言 时间:
2014-07-15 13:10:24
阅读次数:
319
经验:Templates 生成多个 classes 和多个函数,所以任何 template 代码都不该与某个造成膨胀的 template 参数产生相依关系
因非类型模板参数(non-type template parameters) 而造成的代码膨胀,往往可消除,做法是以函数参数或 class 成员变量替换 template 参数
示例:
template //size_t 是非类型模板参数
class SquareMatrix{
public:
//...
分类:
编程语言 时间:
2014-07-15 13:04:39
阅读次数:
307
这次我们来说下列排序:通过使用 .col-md-push-* 和 .col-md-pull-* 类就可以很容易的改变列(column)的顺序。 Bootstrap-Template-07 ...
分类:
其他好文 时间:
2014-07-14 22:44:53
阅读次数:
269
1 简介
自定义指令可以使用 macro 指令来定义,这是模板设计者所关心的内容。 Java 程序员若不想在模板中实 现定义指令 ,而是在 Java 语言中实现指令 的定义,这时 可以使用freemarker.template.TemplateDirectiveModel 类来扩展
2 基本内容
macro 指令自身不打印任何内容,它只是用来创建宏变量,所以就会有一个名为gree...
分类:
其他好文 时间:
2014-07-14 17:09:03
阅读次数:
232
转自:http://blog.csdn.net/xiaowanggedege/article/details/8651236 django模板报错: Requested setting TEMPLATE_DEBUG, but settings are not configured. You must...
分类:
其他好文 时间:
2014-07-14 16:00:46
阅读次数:
302
经验:当我们编写一个 class template, 而它所提供之"与此 template 相关的"函数支持"所有参数之隐式类型转换"时,请将那些函数定义为 "class template内部的 friend 函数"。
示例:
template
class Rational{
public:
Rational(const T &numerator = 0, const T &denominator = 1) // Item 20 对于自定义类型以passed by referenc...
分类:
编程语言 时间:
2014-07-14 13:52:39
阅读次数:
173
经验:声明 template 参数时,前缀关键字 class 和 typename 可互换。请使用关键字 typename 标识嵌套从属类型名称;
示例1:
template
void print2nd(const C &container){
C::const_iterator *x;//歧义。如果const_iterator是个static成员变量,x是个global 变量,这里的 *就是乘
//...
}
示例2:
template
void pr...
分类:
编程语言 时间:
2014-07-14 11:06:02
阅读次数:
206