Assignment: implement a 3 different classes [student, course, grade] and have the code calculate the total number of units the student is taking and calculate the gpa.


So far, my code is working, I don't know how to initialize/declare/call [I'm not really familiar with the c++ lingo], inside the Course class, the "vector<char>grades" and the "char course_grade" and "vector <double> units" which is in the header file, inside the "double Grade::gpa() const" function in the main file.

Help?

Also. Anymore helpful, useful tips for my code would be appreciated. Thanks!




Here's the header file.
Code:
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>

using namespace std;

class Grade {
	Grade (char class_grade){
		(*this).class_grade = class_grade;
	}
	double gpa() const;
private:
	char class_grade;
};



class Course {
public:
	Course (string course_name){
		(*this).course_name = course_name;
	}
	char getGrade() const;
	{
		return class_grade;
	}
	
	vector<double> units;	
	vector<char> grades;
	char course_grade;
	
	void read();
	void print() const;
	void addCourse (string course_name, double course_unit, char course_grade);
	
private:
	string course_name;
	double course_unit;
	vector<string> courses;
};


class Student {
public:
	Student (string student_name){
		(*this).student_name = student_name;
	}
	
	string getName() const {
		return student_name;
	}
	void read();
	void print() const;
private:
	string student_name;
	
};
Here's the main file.
Code:
#include "Hwk5.h"

void Student::read(){
	cout << "Please enter Student name: ";
	getline (cin, student_name);
}
void Student::print() const{
	cout << student_name << endl;
	cout << "================================================" << endl;
	cout << "Course Name \t \tUnits \tGrade" << endl;
	cout << "------------------------------------------------" << endl;
}

void Course::read(){
	cout << "Please enter the course name: ";
	getline (cin, course_name);
	cout << "Please enter the number of units: ";
	cin >> course_unit;
	cin.ignore();
	cout << "Please enter the final grade: ";
	cin >> course_grade;
	cin.ignore();
	addCourse (course_name, course_unit, course_grade);
}

void Course::addCourse(string course_name, double course_unit, char course_grade){
	courses.push_back(course_name);
	units.push_back(course_unit);
	grades.push_back (course_grade);
}

void Course::print() const {
	int i = 0;
	for (i = 0; i < courses.size(); i++)
	{
		cout << courses[i] << "\t \t" << units[i] << "\t" << grades[i] << endl;
	}
}

double Grade::gpa() const
{

}
	


int main (){
	string answer;
	
	Student first ("");
	first.read();
	
	Course second ("");
	
	bool more = true;
	while (more)
	{
		second.read();
		
		cout << "Would you like to enter another class? (y/n) ";
		cin >> answer;
		cin.ignore();
		if (answer == "n" || answer == "N")
			more = false;
	}
	cout << endl << endl;
	first.print();
	second.print();
		
}