2006年11月16日

(原創) 如何使用find() algorithm? (C/C++) (STL)

摘要: find()能在container中,尋找單一的值,若找的到,傳回該iterator,若找不到,則傳回container.end()。 阅读全文

posted @ 2006-11-16 15:32 真 OO无双 阅读(2919) 评论(0) 推荐(0)

(原創) 如何使用remove() algorithm? (C/C++) (STL)

摘要: remove()將移除container中所有的指定元素,但基於不改變Contaier size的原則,remove()只是將要移除的元素搬到contaier後面,若要真正移除,還要搭配contaier.erase()。 阅读全文

posted @ 2006-11-16 15:22 真 OO无双 阅读(1705) 评论(0) 推荐(0)

如何统计出一篇文章出现的文字个数? (高级) (使用std::map)

摘要: 1/**//* 2(C) OOMusou 2006 http://oomusou.cnblogs.com 3 4Filename : CountRepeaterByWordByMap.cpp 5Compiler : Visual C++ 8.0 6Description : Demo how to count repeated words by std::map 7Release ... 阅读全文

posted @ 2006-11-16 12:39 真 OO无双 阅读(624) 评论(0) 推荐(0)

如何统计出一篇文章出现的文字个数? (中级) 使用std::vector

摘要: 1/**//* 2(C) OOMusou 2006 http://oomusou.cnblogs.com 3 4Filename : CountRepeatedWordByVector.cpp 5Compiler : Visual C++ 8.0 6Description : Demo how to count repeated words by vector 7Release... 阅读全文

posted @ 2006-11-16 10:07 真 OO无双 阅读(766) 评论(2) 推荐(0)

(原創) 是否该将local variable宣告在funtion body的最前面? (C/C++) (C)

摘要: 有很多人习惯将local variable宣告在function body的最前面,甚至很多source code和书也都这样写,但事实上这并不是一个好的practice。 阅读全文

posted @ 2006-11-16 08:37 真 OO无双 阅读(645) 评论(0) 推荐(0)

(原創) 为什么在header file中,要使用fully qualified library name? (C/C++)

摘要: The content of a header are copied into our program text by the preprocessor. When we #include a file, it is as if the exact header, it is equivalent to placing the same using declaration in every pro... 阅读全文

posted @ 2006-11-16 02:51 真 OO无双 阅读(388) 评论(0) 推荐(0)

(原創) 何谓const member function? (C/C++)

摘要: const member function是C++独有的,(C语言、C#皆没有,但Java不确定),事实上,C++是一个非常重视const的语言,很多地方都可见到const的踪迹。 阅读全文

posted @ 2006-11-16 02:31 真 OO无双 阅读(9751) 评论(1) 推荐(0)

(原創) 如何使用subscripting的方式新增std::map? (C/C++) (STL)

摘要: std::map提供了两种新增element的方式,一种是c.insert(),和其它container一样,另外一种则是subscripting。 阅读全文

posted @ 2006-11-16 01:00 真 OO无双 阅读(935) 评论(0) 推荐(0)

导航