Code:
class student
{ public:
student();
void classes_added();
void idnumber();
void input();
void output();
void totalcourses();
private:
string firstname;
string lastname;
string idnumber;
string totalcourses;
};
student::student()
{
firstname="";
lastname="";
idnumber="";
totalcourses="";
}
void student::input()
{cout<< "Enter the first name of the student: "<<endl;
cin>>firstname;
cout<<"Enter the last name of the student: "<<endl;
cin>>lastname;
}
void student::classes_added()
{ cout<<"What class number are you adding? "<<endl;
cin>>idnumber;
Is what I have so far for the class student. But I need to also create an entry to take in class numbers; trouble is I am having issues picturing how to do so dynamically based on entry from the user. I would ideally like to ask the user "How many classes are you taking? and take
Code:
nt classSize( 0);
cin >>classSize;
int* myArray = new int[classSize];
if(myArray!=0)
{
}
else
{
//Work with array....
delete[] myArray;
}
But I don't know how to edit objects of the class based on the input from the user. Or if that is even possible.
Here is the entirety of what the teacher wants:
"Make a project, consisting of 3 modules: student.cpp, course.cpp amd register.cpp. Write source and header file for a program that registers students for courses. Design a class student, that stores the name of the student , the id number and array(vector) of all course numbers for which the student is resisted.Design a class course that stores the course number, and array(vector) of the id numbers of all students who are registered for this course. In the register.cpp implement functions that add and drop students and print course lists."