Course newCourse(id,instructor[id2],name,dept);
Course::courseList.insert(std::pair<int,Course>(id,newCourse));
This is the part of the code where I call the constructor of the course class. The instructor[id2] is how I thought it might work but it doesn't.
Course(int courseId, Instructor instructor, string courseName, string dept)
:courseId(courseId),instructor(instructor),courseName(courseName),dept(dept)
{
};
This is the code snippet from the class definition. As you can see 3 of the arguments are an int, and 2 strings. I know how to pass those in fine but its the Instructor instructor argument that I am stuck on.
The Instructor class has each person's info stored in a map with an int as the key. The file I am reading from the build the course class uses an int to relate the course to an instructor. I figured I'd use the int and look into the instructor map to pull out the right person's name but I keep getting undefined function errors.
Example from the file:
0,0,Science,Dept
the first 0 s the course ID number and the second is the instructor ID number.
Edit: different method appears to be the same type of call
code from the method in question
224 string myText(line);
225 istringstream iss(myText);
226 if (!(iss>>id)) id = 0;
227 iss.ignore(1,',');
228 if (!(iss>>id2)) id2 = 0;
229 cout<<"id: "<<id<<" id2: "<<id2<<endl;
230 Enrollment newEnrollment(Course::courseList[id], Student::studentList[id2]);
The constructor declaration:
87 Enrollment(Student student,Course course):student(student),course(course){}
error:
:In static member function `static int Enrollment::loadEnrollment()
230: error: no matching function for call to `Enrollment::Enrollment(Course&, Student&)'
81: error: candidates are: Enrollment::Enrollment(const Enrollment&)
88: error: Enrollment::Enrollment()
87: error: Enrollment::Enrollment(Student, Course)