I need some help here. I am having to follow some very specific, very stupid, criteria for this program. It is required to have two classes: class Student
and class Roster
. Those cannot go away. Nor can the enumerated data type, enum DegreeProgram
defined in degree.h
. Anyway, the following method is defined in roster.cpp
void Roster::add(string& studentID, string& firstName, string& lastName, string& emailAddress,
int age, int daysInCourse1, int daysInCourse2, int daysInCourse3, DegreeProgram degreeProgram)
{
/* The daysInCourseArray[] constructs an array using the daysInCourse parameters given to the function.
* Then, for the rest of the parameters (and the newly constructed daysInCourseArray[]), it instantiates a new
* Student class that is intended to be added to the classRosterArray of pointers. */
int daysInCourseArray[3] = {daysInCourse1, daysInCourse2, daysInCourse3};
Student addStudent(studentID, firstName, lastName, emailAddress, age, daysInCourseArray, degreeProgram);
/* The function treats the roster like a stack. rosterIndex points to a different index in the classRosterArray
* each time the function is run. rosterIndex starts at -1, as defined by the constructor, and this function
* increments it to 0 before performing an operation using the local student instance variable. The next time the
* function is run, rosterIndex should still be pointing to 0, and so the function will increment it once again to 1.
* This creates an iterable approach despite the asynchronous connections to the function each time. */
if (rosterIndex - 1 < 5) *classRosterArray[++rosterIndex] = addStudent;
}
My compiler is saying that my instance of Student is invoking an undefined reference to the Constructor, but I have both a default constructor and an overloaded constructor defined in student.cpp
.
//default constructor that sets all variables to empty strings
Student::Student()
{
setStudentID("");
setFirstName("");
setLastName("");
setEmail("");
setAge(0);
int defaultDaysInCourse[3] = {0,1,2};
setDaysInCourse(defaultDaysInCourse);
setDegreeProgram(SOFTWARE);
}
//overloaded constructor
Student::Student(string& studentID, string& firstName, string& lastName, string& email,
int age, int daysInCourse[3], DegreeProgram degree)
{
setStudentID(studentID);
setFirstName(firstName);
setLastName(lastName);
setEmail(email);
setAge(age);
setDaysInCourse(daysInCourse);
setDegreeProgram(degree);
}