I'm a C++ beginner trying to implement Course class which has a stl unordered_map as member variable to store the students' grades.
#include <iostream>
using namespace std;
class Course{
string course_name;
Supervisor PI;
Teacher TA;
unordered_map<Student, int> grades;
public:
Course(string name,
void get_student_grade(Student person){
return grades. ;
}
void printGrades(){
return ;
}
};
class Student{
string name;
public:
Student(string namee):name(namee){}
};
int main(){
Course calculus{"calculus", Student Matt("Matt"), Student James("James"),
Student Michelle("Michelle"), Student Ashley("Ashley"), Student Karen("Karen")};
calculus.printGrades();
}
I am trying to create a course constructor that takes the course string and arbitrary number of student object arguments and store it in unordered_map.
So far Google has taught me there is something called variadic template to enable arbitrary number of arguments, but I don't seem to get how to apply that in my case. Also, would it be possible to store Student object as key for the unordered_map? By this I mean when I do sth like
return grades[James];
, the hash table would search for string James and then return the value.
Thanks for helping out!