09 2012 档案

摘要:回调函数(callback)与仿函数(functor)很多时候从用途上来看很相似,以致于我们经常将它们相提并论。例如:inline bool compare(int a, int b){ return a > b;} struct comparer { bool operator()(int a, int b) const { return a > b; }}; void main(){ std::vector<int> vec, vec2; std::sort(vec.begin(), vec.end(), compare); std::sort(vec2.beg.. 阅读全文
posted @ 2012-09-17 17:46 Zhaoyier 阅读(383) 评论(0) 推荐(0)
摘要:#include <iostream>#include <ctime>#include <cstdio>struct tm calc_date_diff(time_t& _second){ //计算年,如果只告诉秒,那么年的概念中是否可以忽略掉闰年的概念的, 因为这个时间段本来就不是一个连续的时间段 //如果你不忽略掉闰年的概念,怎么去计算断断续续的时间总和所持续的时间 struct tm timeinfo; timeinfo.tm_year = _second/(365*24*60*60); _second -= timeinfo.tm_year* 阅读全文
posted @ 2012-09-10 17:29 Zhaoyier 阅读(337) 评论(0) 推荐(0)