in Main.cpp I call the add function which adds student objects to classRosterArray
roster.add(id, firstName, lastName, email, age, daysInCourse1, daysInCourse2, daysInCourse3, degree);
roster.remove("A3");
Relevant part of add function in Roster.cpp:
Student* student = new Student(studentID, firstName, lastName, emailAddress, age, degreeprogram, daysInCourses);
classRosterArray[numberOfStudentsAdded] = student;
In the 'remove' function a studentID is passed in. If it matches a studentId in classRosterArray then that value is deleted:
void Roster::remove(string studentID) {
for (int i = 0; i < 5; i++) {
if (classRosterArray[i]->getId() == studentID) {
cout << "removed: " << studentID << endl;
delete classRosterArray[i];
printAll();
return;
}
else {
cout << "The student with the ID: " << studentID << " was not found\n";
}
}
}
edited to add in printAll() function
void Roster::printAll() {
//prints a complete tab-separated list of student data, each data point indented (tab)
for (int i = 0; i < 5; i++) {
classRosterArray[i]->print();
}
}
But printAll() still prints all values regardless. What am I doing wrong?
...getID() == studentID