STL Vector没有find()成员函数,只能用泛型find()

来源:互联网 发布:unity3d 如何制作ar 编辑:程序博客网 时间:2024/06/06 00:30
  1. #include <iostream>  
  2. #include <vector>  
  3. #include <algorithm>  
  4. using namespace std;  
  5.   
  6. int main()  
  7. {  
  8.     vector<int> v;  
  9.     v.push_back(10);  
  10.     v.push_back(23);  
  11.     v.push_back(35);   
  12.       
  13.     if(find(v.begin(), v.end(), 23) == v.end())  
  14.     {  
  15.         cout << "no1" << endl;  
  16.     }  
  17.       
  18.     if(find(v.begin(), v.end(), 12) == v.end())  
  19.     {  
  20.         cout << "no2" << endl;  
  21.     }  
  22.       
  23.     return 0;  
  24. }  
  25. 结果是:no2
原创粉丝点击