So I am in a C++ class for school and am doing a project where I must create 2 classes CStudent and CCourse where CStudent includes an array of 5 CCourses being the classes the student takes. I need to overload the insertion operator to display all of the information in CStudent, including all of the classes, except when the data in the array position is the default data for CCourse... I realize I am probably not explaining this very well, but I created a function to display courses when the course in the array does not have the default data, but I cannot get it to be called in the overloaded insertion operator... I can't figure out what to do. Any help would be great?
My teacher provided me with a main function that does work when the code we have written works properly. I simply turned that line into a comment to test the rest of my code. Everything works properly except for that one line and the total enrolled units displays as 0.
cout << "Information of the default course: \n" << defaultCourse;
CCourse math101("MA101", "Arithemetic Math", 3);
cout << "Information of the course Math101: \n" << math101;
CCourse csci123("C0123", "Introduction To Programming", 4);
cout << "Current ID of the course Computer Science 123: \n" << csci123.getid() << endl;
csci123.title = "Introduction To Programming with C++";
cout << "Updated information of the course Computer Science 123: \n" << csci123 << endl;
cout << "Information of the default student: \n" << defaultStudent;
CStudent firstStudent("S0000", "Toyota", "Camry", 'S', 'M', 3.5);
cout << "\nInformation of the first student: \n" << firstStudent;
cout << "\nChange the ID of the first student to S0001. \n";
cout << "Update the GPA of the first student to 3.65. \n";
cout << "\nThe new ID of the first student is: " << firstStudent.getId() << endl;
cout << "\nThe new GPA of the first student is: " << firstStudent.getGpa() << endl;
cout << "\nEnroll Math 101 for the first student.";
cout << "\nEnroll CSCI123 for the first student.";
cout << "\nUpdated information of the first student: \n" << firstStudent;
cout << "\nDrop Math 101 for the first student.";
cout << "\nLast information of the first student: \n" << firstStudent;
I'm obviously modifying Units improperly there. And we have been using void main for all of our main functions since our second assignment, so that isn't the problem. void mains work fine. That way we dont have to return 0 at the end. I also still need to find a way to get it to display the classes..
Thank you for the input but that is not what I require assistance with. The sloppiness of my code should show I'm not going for perfection, just for it to do the job. This is only my first programming class, I am a beginner, I imagine I will get better as I go along. Right now, all I need is help with getting the units to display properly.