#include <iostream>
#include <string>
using namespace std;


struct Course;
ostream &operator<<(ostream &os, Course c);


struct Course {
	string name;
	Course(string n) {
		name = n;
	}
	Course(const Course &c) {
		cout << "Copying course" << endl;
		name = c.name;
	}
	Course &operator=(const Course &c) {
		cout << "Assigning course" << endl;
		name = c.name;
		return *this;
	}
};


struct Student {
	int id;
	Course *courses[5];
	int size;
	Student(int num) {
		id = num;
		for (int i = 0; i < 5; i++) {
			courses[i] = new Course("Course");
		}
		size = 0;
	}
	Student(const Student &s) {
		cout << "Copying student" << endl;
		id = s.id;
		for (int i = 0; i < 5; i++) {
			Course *temp = new Course(s.courses[i]->name);
			courses[i] = temp;
		}
	}
	Student &operator=(const Student &s) {
		cout << "Assigning student" << endl;
		id = s.id;
		for (int i = 0; i < 5; i++) {
			courses[i] = s.courses[i];
		}
		return *this;
	}
	~Student() {
		for (int i = 0; i < 5; i++) {
			delete courses[i];
		}
	}
	void print() {
		cout << id << ": " << endl;
		for (int i = 0; i < 5; i++) {
			cout << courses[i]->name << endl;
		}
	}
	void addCourse(Course *c) {
		delete courses[size];
		courses[size] = c;
		size++;
	}
};

ostream &operator<<(ostream &os, Course *c) {
	return os << c->name << endl;
}

int main() {
	Student one(2342134);
	Course* cs246 = new Course("cs246");
	Course* cs245 = new Course("cs245");
	one.addCourse(cs246);
	one.addCourse(cs245);
	one.print();
	Student two = one;
	two.print();
}

