导航

2016年6月20日

摘要: #include int main() { std::function fn[100]; for( int i = 0; i fn[100] 等于缩写了下面的: typedef int (*TypeFn)(); TypeFn fn[100]; 阅读全文

posted @ 2016-06-20 23:32 codetask 阅读(124) 评论(0) 推荐(0)

摘要: //错误! //返回的是local对象,但已被销毁 const string& getDog() { string dog = string( "Budi" ); return dog; } //不推荐,应尽量避免使用new //返回申请在heap上的对象 const string& getDog() { string* dog = new string( "Bu... 阅读全文

posted @ 2016-06-20 23:21 codetask 阅读(232) 评论(0) 推荐(0)

摘要: 1 // 比如 2 // 3 // 这段实现了重载操作符 String + char* 的操作 4 5 const char* operator+(const char* str) { 6 int len = 0; 7 if( str ) 8 len = strlen(str); 9 if(pTmpString) 10 ... 阅读全文

posted @ 2016-06-20 23:18 codetask 阅读(175) 评论(0) 推荐(0)

摘要: PYTHON的Range类非常好用,所以用C++来简单实现下: 之后测试下: 阅读全文

posted @ 2016-06-20 16:49 codetask 阅读(645) 评论(0) 推荐(0)

摘要: BLOG: http://codetask.org GIT: http://git.oschina.net/codetimer 阅读全文

posted @ 2016-06-20 16:16 codetask 阅读(93) 评论(0) 推荐(0)