You need to pass an instance of MyCourse
which contains allStudents
to either the constructor of MyStudent
or the member function addAssignScore
.
Something like this:
void addAssignScore(const MyCourse& course){
for (int f = 0; f < course.allStudents.size() ; f++) {
double sc;
cout << "What is " << course.allStudents[f] << "'s score in the assignment ?" << endl;
cin >> sc;
assignScores.push_back(sc);
}
}
I understand you want to make the deadline of the assignment, but your design is suboptimal. Your are not using the classes correctly, merely as wrappers for orthogonal containers and functions. The only relation they have, is the equal numbers of students and scores. You could just as well used a std::map<std::string, double>
for that.
Edit to answer your comment:
In your main.cpp. You use it like this:
#include "MyStudent.h"
#include "MyCourse.h"
//...
int main()
{
//...
MyCourse course;
course.addStudent();
MyStudent student;
student.addAssignScore(course);
//...
}