instead use std::set<Passenger> after overloading operator < for class Passenger, then use the insert method which returns a std::pair<iterator, bool>, the bool being set to true if new element was inserted, false otherwise http://stackoverflow.com/questions/9586281/set-detect-insertion-failure
Add a member function to the class Passenger which returns the unique id of he passenger.
Something like:
1 2 3 4 5 6 7 8 9
class Passenger
{
private:
Person personInfo;
// ...
public:
// ...
std::string passenger_id() const { return personInfo.get_id() ; }
};
Then in FlightReservation::CreateNewPassenger, first check if a passenger with this particular id already exists in the vector of passengers (iterate through the vector to see if there is a match for this id).
you haven't shown FlightReservation.h but if an instance of this type pertains to a particular flight then the associated container (std::vector or std::set) should be a data-member of this class