STL
文章平均质量分 79
ilun
这个作者很懒,什么都没留下…
展开
-
STL 实践(for_each() getline sort random_shuffle的使用)
#include iostream>#include string>#include fstream>#include vector>#include algorithm>using namespace std;struct Review ...{ std::string title; int rating;};bool operator(const Review & r1, co原创 2007-06-04 13:30:00 · 960 阅读 · 0 评论 -
读写文件精华 (转)
ASCII 输出:ofstream fout; fout.open("output.txt"); //ofstream fout("output.txt");int num = 150;char name[] = "John Doe";fout fout fout fout.close(); //Here is a number: 150 Now here is a string: Jo转载 2007-06-04 13:47:00 · 498 阅读 · 0 评论 -
STL实践(count_if)
vs2003编译器对count_if的实现格式与规范中例子不一样。count_if的第3个参数输入是一个函数对象,应该是一个返回bool值的函数。在下例中构造了一个类,重载了bool operator() (string& SalesRecord) ,值得注意。引用自http://stl.winterxy.com/html/000013.html#include iost原创 2007-06-04 16:09:00 · 716 阅读 · 0 评论 -
STL实践(string&IO)
直接从文件中读取#include iostream>#include string>#include fstream>#include cstdlib>#include windows.h>using namespace std;inline bool getItem(string &wholeFile,string &item,char separator,int &stat);int原创 2007-06-04 10:17:00 · 622 阅读 · 0 评论 -
工欲善其事,必先利其器 一些类库和资源(zz) C++
1,前言 无数次听到“我要开始学习C++!”的呐喊,无数次听到“C++太复杂了,我真的学不会”的无奈。Stan Lippman先生曾在《C++ Primer》一书中指出“C++是最为难学的高级程序设计语言之一”,人们常将“之一”去掉以表达自己对C++的敬畏。诚然,C++程序设计语言对于学习者的确有很多难以逾越的鸿沟,体系结构的庞大,应接不暇并不断扩充的特性……除此之外,参考资料之多与冗杂使转载 2007-06-06 14:53:00 · 1866 阅读 · 0 评论 -
typedef 为复杂的声明定义一个新的简单的别名(zz)
为复杂的声明定义一个新的简单的别名。方法是:在原来的声明里逐步用别名替换一部分复杂声明,如此循环,把带变量名的部分留到最后替换,得到的就是原声明的最简化版。举例: 1. 原声明:int *(*a[5])(int, char*); 变量名为a,直接用一个新别名pFun替换a就可以了: typedef int *(*pFun)(int, char*); 原声明的最简化版: pFun a[5];转载 2007-06-11 18:35:00 · 779 阅读 · 0 评论