摘要: windows中是ctrl+z但是我在vc6下不好使, 有时候要要好几下,有时候ctrl+z后要回车,可以用ctrl+a,也可以用ctrl+d;linux下是ctrl+d istream_iterator<int> iput(cin), eos; ofstream efile("evenfile"); ostream_iterator<int> evenfile(efile, "\n"); ofstream ofile("oddfile"); ostream_iterator<int> oddfil 阅读全文
posted @ 2011-07-30 19:16 lidan 阅读(629) 评论(0) 推荐(0) 编辑
摘要: 1.当参数推演失败, 产生ambiguous,可以明白指定参数min5<double>(dobj, fobj);2.当编译器无法推演出返回类型时template <class T1, class T2, class T3>T1 sum(T2, T3);指定参数时, 只有尾部的参数可以不写如:sum<double>(fobj, dobj);//返回值类型T1是double, T2是float, T3是doublesum<double, ,double>(fobj, dobj);//错误, 只能省略后面的 阅读全文
posted @ 2011-07-30 15:48 lidan 阅读(348) 评论(0) 推荐(0) 编辑
摘要: 函数对象的实现简单形式包括一个被重载的函数调用操作符, 如下:还可以加入模板, 或者加入构造函数, 添加私有成员等class Lessthan{public:bool operator()(int a, int b){return a < b;}}典型情况下,函数对象被当做实参传递给算法, 也可以独立的定义函数对象。stable_sort(sentences.begin(), sentences.end(), LessThan());Lessthan lt;bool b = lt(3, 5); 阅读全文
posted @ 2011-07-30 12:49 lidan 阅读(149) 评论(0) 推荐(0) 编辑
摘要: 在写程序时 经常莫名其妙的出现一些 未定义错误,如下面, 是因为用了c++的名字空间std中的类型;忘了加上using namespace std;语句error C2143: syntax error : missing '; ' before ' < ' error C2143: syntax error : missing '; ' before ' < ' error C2061: syntax error : identifier 'vector ' error C2061: syntax e 阅读全文
posted @ 2011-07-30 11:22 lidan 阅读(344) 评论(0) 推荐(0) 编辑