I have created an iterator for a vector and i need to create a return type for an object found in the vector.
vector<Student>::iterator StudentRecord::find(const string& studentName){
vector<Student>::iterator find;
for(find = students.begin(); find != students.end(); find++) {
if(find->getName() == studentName){
return find;
// Not sure if i am allowed to return find or if i need to specify where abouts in the vector it is located.
}
else {
cout << "Message: student studentName is not found " << endl;
}
}
}
And if i am to call this function in another function can i use:
Found = vector<Student>::iterator StudentRecord::find(const string& studentName);
where found is an object type or is it a string type? Im not sure.