- std::find
- std::find_if
- std::bind
- std::distance
- lambda
详见:http://www.cplusplus.com/reference/algorithm/find/
#include <algorithm>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
class Item {
private:
int mId;
std::string mName;
public:
Item(int id, std::string name) : mId(id), mName(name) {
}
std::string getName() const {
return mName; }
int getId() const {
return mId; }
bool operator==(const Item& obj2) const {
return (this->getName().compare(obj2.getName()) == 0) &&
(this->getId() == obj2.