c/c++最佳参考网站
时间:2010-09-02 来源:saltedLinux
C和C++的参考书非常之多,但是他们都一个共同的特点,动辄七八百页,太厚了,很不便于携带,作为一名开发人员,我也是深受其苦。不过,我一年前发现了一个非常好的网站,专门帮助C++开发人员的,现在与大家分享一下。<原创作者:Yujia,更多内容参见 http://flyingyujia.cublog.cn ,仿盗版,不得已而为之>
网址:http://www.cplusplus.com/reference/
另外还有一个,不过不如这个全面:
网址:http://www.cppreference.com/wiki/cn/start
相信在这里,你能查到任何库里的东西和详细的介绍。不过大家可要提高英文水平哦。
<原创作者:Yujia,更多内容参见 http://flyingyujia.cublog.cn ,仿盗版,不得已而为之>
举例:
find_first_of
function template
<algorithm>
<原创作者:Yujia,更多内容参见 http://flyingyujia.cublog.cn ,仿盗版,不得已而为之>
All the elements in [first2,last2) are compared to the each of the values in [first,last) until a match is found. The comparison is performed by either applying the == operator, or the template parameter comp (for the second version). <原创作者:Yujia,更多内容参见 http://flyingyujia.cublog.cn ,仿盗版,不得已而为之>
template <class ForwardIterator1, class ForwardIterator2>
ForwardIterator1 find_first_of ( ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2 );
template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
ForwardIterator1 find_first_of ( ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2,
BinaryPredicate pred );
Find element from set in range
Returns an interator to the first occurrence in the range [first1,last1) of any of the elements in [first2,last2).<原创作者:Yujia,更多内容参见 http://flyingyujia.cublog.cn ,仿盗版,不得已而为之>
All the elements in [first2,last2) are compared to the each of the values in [first,last) until a match is found. The comparison is performed by either applying the == operator, or the template parameter comp (for the second version). <原创作者:Yujia,更多内容参见 http://flyingyujia.cublog.cn ,仿盗版,不得已而为之>
Example
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
// find_first_of example
#include <iostream>
#include <algorithm>
#include <cctype>
#include <vector>
using namespace std;
bool comp_case_insensitive (char c1, char c2) {
return (tolower(c1)==tolower(c2));
}
int main () {
int mychars[] = {'a','b','c','A','B','C'};
vector<char> myvector (mychars,mychars+6);
vector<char>::iterator it;
int match[] = {'A','B','C'};
// using default comparison:
it = find_first_of (myvector.begin(), myvector.end(), match, match+3);
if (it!=myvector.end())
cout << "first match is: " << *it << endl;
// using predicate comparison:
it = find_first_of (myvector.begin(), myvector.end(),
match, match+3, comp_case_insensitive);
if (it!=myvector.end())
cout << "first match is: " << *it << endl;
return 0;
}
<原创作者:Yujia,更多内容参见 http://flyingyujia.cublog.cn ,仿盗版,不得已而为之> |
相关阅读 更多 +










