-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudent.cpp
More file actions
61 lines (45 loc) · 983 Bytes
/
Student.cpp
File metadata and controls
61 lines (45 loc) · 983 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "header.h"
#include "student.h"
student::student(string name)
{
student_name = name;
}
string student::getName()
{
return student_name ;
}
bool student::addcourse(course* c)
{
for (int i = 0; i < courses.size(); i++) {
if ((c->getName()) == courses[i]->getName()) {
return false;
}
}
courses.push_back(c);
c->addStudent(this);
}
student::~student()
{
}
void student::removedFromCourse(course* c)
{
int x = 0;
for (int i = 0; i < courses.size(); i++) {
if (c->getName() == courses[i]->getName()) {
courses.erase(courses.begin() + i);
x = 1;
}
}
if (x ==0) { cout << "course does not exist"; }
c->remove1(student_name);
}
ostream& operator<<(ostream& coutt, student s2)
{
coutt << "name of student is :" << s2.getName() << endl;
coutt << "The courses in which the student registered:- "<<endl;
for (int i = 0; i < s2.courses.size(); i++) {
coutt <<i+1<<"-" << s2.courses[i]->getName()<<endl;
}
cout << endl;
return coutt;
}