![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
STL源码剖析
快乐的一只程序猿
快乐的一只,一只快乐的我,热爱编程,热爱生活!
展开
-
临时对象的产生和运用以及仿函数的用法
临时对象即无名对象。如果临时对象的出现不在程序员的预期之下,则会造成效率上的负担。而有时候,刻意制造的临时对象又使得程序看起来简洁明快。STL最常将此算法应用于仿函数和算法的搭配上。如(摘抄于STL源码剖析):# include# include# includeusing namespace std;templateclass print{public: void operato原创 2016-05-19 14:12:52 · 395 阅读 · 0 评论 -
实现一个简单的迭代器
# includeusing namespace std;class INT{ friend ostream& operator <<(ostream& os, const INT& i);private: int m_i;public: INT(int i) :m_i(i) {} INT& operator ++()//迭代器++的实现 { ++(this->m_原创 2016-05-21 22:20:24 · 1070 阅读 · 0 评论 -
STL的仿函数 和函数指针传参
C_age.h//在C语言时代,要将函数当做参数传递,唯有通过函数指针//以下是用函数指针实现参数传递的示例# include # includeusing namespace std;int fcmp(const void *elem1, const void*elem2);void Test(){ int ia[10] = { 32, 92, 67, 58, 10, 4,原创 2016-05-21 22:27:31 · 1086 阅读 · 0 评论