用stl的find方法查找一个包含简单类型的vector中的元素是很简单的,例如vector strVec; find(strVec.begin(),strVec.end(),”aa”);假如vector包含一个复合类型的对象呢比如class A { public: A(const std::string str,int id) { this->str=str; this->id=id; } private: std::string str; int id; };这个时候一般的想法是写个函数遍历这个vector,然后进行比较查找。实际上在使用STL的时候,不建议使用循环遍历的查找方 Read More
posted @ 2013-08-28 10:45
星语海蓝
Views(7412)
Comments(0)
Diggs(1)

浙公网安备 33010602011771号