Question: Can you fix my code it says: On line 7 3 and 8 5 [ Error ] 'class studentList' has no memeber named 'end' #include

Can you fix my code it says: On line 73 and 85[Error] 'class studentList' has no memeber named 'end'
#include
#include
#include
#include #include < list>
using namespace std;
ifstream infile;
struct studentNode {
string firstName;
string lastName;
string id;
double gpa;
};
class studentList {
list students;
public:
void addStudent(const studentNode& student){
students.push_front(student);
}
void deleteStudent(const string& id){
for (list::iterator it = students.begin(); it != students.end(); ++it){
if (it->id == id){
students.erase(it);
cout << "Student ID: "<< id <<" has been deleted" << endl;
return;
}
}
cout << "Student with ID: "<< id <<" not found" << endl;
}
list::iterator locateStudent(const string& id){
for (list::iterator it = students.begin(); it != students.end(); ++it){
if (it->id == id){
return it;
}
}
return students.end(); // Return end iterator if not found
}
void print(){
for (list::iterator it = students.begin(); it != students.end(); ++it){
cout << it->firstName <<""<< it->lastName <<""<< it->id <<""<< it->gpa << endl;
}
cout << endl;
}
};
void processAdd(studentList& students){
studentNode s;
infile >> s.firstName;
infile >> s.lastName;
infile >> s.id;
infile >> s.gpa;
students.addStudent(s);
}
void processDelete(studentList& students){
string id;
infile >> id;
students.deleteStudent(id);
}
void processSearch(studentList& students){
string id;
infile >> id;
list::iterator it = students.locateStudent(id);
Line 73: if (it != students.end()){
cout << "Information Located: "<< it->firstName <<""<< it->lastName <<""<< it->id <<""<< it->gpa << endl;
} else {
cout << "Information: "<< id <<" cannot be found." << endl;
}
}
void processChange(studentList& students){
string id;
double gpa;
infile >> id >> gpa;
list::iterator it = students.locateStudent(id);
Line 85: if (it != students.end()){
it->gpa = gpa;
} else {
cout << "Student ID "<< id <<" not found" << endl;
}
}
int main(){
char code;
studentList students;
infile.open("updates.txt");
while (infile >> code){
switch (code){
case 'A':
case 'a':
processAdd(students);
students.print();
break;
case 'D':
case 'd':
processDelete(students);
students.print();
break;
case 'S':
case 's':
processSearch(students);
break;
case 'C':
case 'c':
processChange(students);
students.print();
break;
default:
cout << "Invalid code "<< code << endl;
break;
}
}
return 0;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!