Ich erhalte ein Undefined Symbole für Architektur Fehler beim Kompilieren.C++ Vektor Find() Überladener Operator - Fehler
Verwenden Sie einen Vektor, Find() - Algorithmus und nicht überladene Operatorfunktion.
Einige Hinweise für den Fehler wären willkommen.
#include <stdio.h>
#include <iostream>
#include <stdexcept>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
struct person
{
char firstInitial;
string firstName;
person(const char fi, const string fn)
{
firstInitial = fi;
firstName = fn;
};
char getInitial()
{
return firstInitial;
};
string getName()
{
return firstName;
};
bool operator==(const person& r);
};
bool operator==(const person& r, const person& x)
{
return x.firstInitial == r.firstInitial;
}
int main (int argc, char *argv[])
{
vector<person> myvector;
vector<person>::iterator itr;
myvector.push_back(person('j', "john"));
myvector.push_back(person('s', "steve"));
myvector.push_back(person('c', "candice"));
itr = find (myvector.begin(), myvector.end(), person('s', ""));
if (itr != myvector.end())
cout << "First Name: " << itr->getName() << '\n';
else
cout << "NOT Found" << '\n';
}