1.remove_if函数(算法)的原型: template < class ForwardIterator, class Predicate > ForwardIterator remove_if ( ForwardIterator first, ForwardIterator last,Predicate pred ); 其中ForwardIterator是前向迭代器类型,例如vector<int>::iterator,vector<float>::iterator。Predicate是一个二元函数。 二元函数是继承了binary_function类,并 Read More
posted @ 2011-08-01 21:19
iliveido
Views(462)
Comments(0)
Diggs(0)
第一个仿函数的demo:仿函数,就是实现了operator()重载的类。“Generically, function objects are instances of a class with member function operator() defined. This member function allows the object to be used with the same syntax as a regular function call,and therefore it can be used in templates instead of a pointer to a f Read More
posted @ 2011-08-01 15:56
iliveido
Views(540)
Comments(2)
Diggs(0)
c++文件的打开模式有六个:in,out,ate,app,trunc,binary。如果你输出它们cout<<ios_base::in<<endl;的话,会看到它们的值分别是1,2,4,8,16,32.但是,它们的值并不能说明什么,因为我不知道fstream类的构造函数是怎样通过它们的组合的值来决定文件打开时的状态的。问题:按照排列组合的知识,6个模式的组合数等于2^6-1,即63种组合。这其中哪些组合是无效的?我想说的是,其实这六种模式是互相影响的,所以我没有办法看到一种组合就判别出文件打开时的状态。最让我头痛的就是两个问题:如果文件不存在,会不会创建?如果文件存在, Read More
posted @ 2011-08-01 12:34
iliveido
Views(475)
Comments(2)
Diggs(0)

浙公网安备 33010602011771号