I have a header file called StudentRecord.cpp which declares the function:
vector<Student>::iterator find (const string& studentName);
In my Student Record.cpp file i have written the folloing code:
vector<Student>::iterator StudentRecord::find(const string& studentName){
vector<Student>::iterator find;
for(find = students.begin(); find != students.end(); find++) {
if (students[find].getName() == studentName) {
return students[find];
}
else {
cout << "Message: student studentName is not found " << endl;
}
}
}
The problem I have in with the part students[find].getName() == studentName
. My compiler gives an error no match for operator[]
in StudentRecord*this->StudentRecord::students[find]
. Please note that Students is a vector object and i wish to find a students name. If the name is found then this function needs to return a vector::iterator type.
If anyone has any idea of how to fix the mistakes? Please Help