How to use find algorithm with a vector of pointers to objects in c++?

后端 未结 4 2129
逝去的感伤
逝去的感伤 2021-02-07 07:04

I want to find in a vector of Object pointers for a matching object. Here\'s a sample code to illustrate my problem:

class A {
public:
    A(string a):_a(a) {}
          


        
4条回答
  •  萌比男神i
    2021-02-07 07:57

    Try using find_if instead. It has a parameter for a predicate where you can decide exactly how to check wheter you found the right element.

    http://www.sgi.com/tech/stl/find_if.html

提交回复
热议问题