how to use the find function

Excerpt of code:

Researched find function appears this should work

int main()
{
vector<Person*>people;
vector<Car*> cars;
string name = "";
Car * d;
Car * o;
string person_owner;
string person_driver;
int age = 0;
string model;
int testValue = 0;

while (testValue != -1)
{
//Start Input for People
cout << "Enter Driver Name: ";
cin >> name;
cout << "Enter Age: ";
cin >> age;
people.push_back(new Person(name, age));

// Start Input for Cars
cout << "Enter car model, owner name, driver name: ";
cin >> model >> person_owner >> person_driver;

d = find(person_owner, people); //find doesn't work
o = find(person_driver, people); //same here

cars.push_back(new Car(model, o, d));

error code:
error C2664: 'Person *find(std::string,std::vector<Person,std::allocator<_Ty>> &)' : cannot convert parameter 2 from 'std::vector<Person *,std::allocator<_Other>>' to 'std::vector<Person,std::allocator<_Ty>> &'

Full code can be found at:
http://pastebin.com/D6atcXvW

Reference my name "cplusplusnub" if this was a very silly error. Any guidance on the syntax or what this code should look like would be much appreciated, Thank you.
I have to wonder if you looked up the find algorithm at all or if you just decided this is the way it should work?

http://en.cppreference.com/w/cpp/algorithm/find
closed account (2b5z8vqX)
The find function expects an object of type std::vector<Person>, not std::vector<Person*>. To fix this you could replace the template argument in the declaration of the 'people' object with Person or change the type of the second parameter of the find function.

I have to wonder if you looked up the find algorithm at all or if you just decided this is the way it should work?

The function he is attempting to use is not the find function from the C++ Standard Library.

1
2
3
4
5
6
7
8
9
10
Person*find(string n, vector<Person>&people)
{
	for (int i = 0; i < people.size(); i++)
	{
		if (n == people[i].getName())
			return &(people[i]);
		else
			return 0;
	}
};
Topic archived. No new replies allowed.