-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathStudent.cc
41 lines (34 loc) · 973 Bytes
/
Student.cc
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
#include "Student.h"
#include <iostream>
using namespace std;
Student::Student(const std::string& name, int id) :
Person(name) {
id_ = id;
courses_ = new std::vector<std::string>();
cout << "Student(" << name << ", " << id << ") called" << endl;
}
Student::~Student() {
delete courses_;
courses_ = 0;
cout << "~Student() called for name:" << name() << " and id: " << id_ << endl;
}
void Student::print() const {
cout << "I am Student " << name() << " with id " << id_ << endl;
cout << "I am now enrolled in " << courses_->size() << " courses." << endl;
}
void Student::addCourse(const std::string& course) {
courses_->push_back( course );
}
void
Student::printCourses() const {
cout << "student " << name()
<< " currently enrolled in following courses:"
<< endl;
for(int i=0; i<courses_->size(); ++i) {
cout << (*courses_)[i] << endl;
}
}
const std::vector<std::string>*
Student::getCourses() const {
return courses_;
}