tr1 的 bind 和 function

首先来看两个文章,function/bind的救赎(上),http://blog.csdn.net/myan/arti…,以boost::function和boost:bind取代虚函数,http://blog.csdn.net/solstice/…,前者讲背景和理论,后者讲实际操作和细节对比,读来酣畅淋漓,醍醐灌顶 这么好的东西,当然要想着怎么在现有的环境条件下用起来,没有 boost,……

阅读全文

最长公共子序列

#include <stdio.h> #include <string.h> static const int MAX = 100; char str1[MAX], str2[MAX], str3[MAX]; int c[MAX][MAX], f[MAX][MAX]; inline int max(int a, int b) { return a>b ? a : b; } int dp(int i, int j) { if (c[i][j] == -1) { if (i==0 || j==0) { ……

阅读全文

对引用取地址

今天突然想到,如果我们对一个引用取地址,那么会怎么样呢,例如这样 #include <stdio.h> class CNumber { public: int n; }; void printByPointer(CNumber* pNumber) { printf("%d\n", pNumber->n); } void printByRef(CNumber& oNumber) { printf("%d\n", oNumb……

阅读全文

最简 Makefile

依赖于 Makefile 的自动推导,可以写出非常简化的 Makefile,假设目录下有有 Number.cpp 的单个 cpp 文件,内含 main 函数,那么,Makefile 可以这样写 all: Number 是的,就一行,all 作为默认 target,Number 作为依赖,自动推导出依赖源文件 Number.c*,如果是 cpp,得到编译器 g++,如果是 c,得打编译器 cc,然……

阅读全文