First Class
student.cpp
Go to the documentation of this file.
1 #include "student.h"
2 #include <algorithm> // erase
3 #include <string>
4 #include <vector>
5 using namespace std;
6 
8 : _name(), _matr_nr(), _skz()
9 {
10  //ctor
11 }
12 
13 Student::Student(const string& fname, const string& matrikel, const int studium)
14 : _name(fname), _matr_nr(matrikel), _skz(1,studium)
15 {
16  //ctor
17 
18 }
19 
20 Student::Student(const string& fname, const string& matrikel, const vector<int>& studium)
21 : _name(fname), _matr_nr(matrikel), _skz(studium)
22 {
23  //ctor
24 
25 }
26 
27 void Student::Setname(const string& val) { _name = val; }
28 
29 void Student::Add_SKZ(const int skz)
30 {
31  vector<int>::iterator it;
32  it = find(_skz.begin(),_skz.end(), skz);
33  if ( it == _skz.end()) _skz.push_back(skz);
34 }
35 
36 void Student::Del_SKZ(const int skz_in)
37 {
38  //vector<int>::iterator it;
39  auto it = std::find(_skz.begin(),_skz.end(),skz_in);
40  if ( it != _skz.end() ) _skz.erase(it);
41  return;
42 }
43 
44 
45 ostream& operator<<(ostream& s, const Student& rhs)
46 {
47  s << rhs._name << " : ";
48  //s << rhs.skz << endl;
49  for (unsigned int k=0; k<rhs._skz.size(); ++k)
50  {
51  s << rhs._skz.at(k) << " ";
52  }
53  return s;
54 }
55 
56 istream& operator>>(istream& s, Student& rhs)
57 {
58  s >> rhs._name;
59  int tmp;
60  s >> tmp;
61  rhs.Add_SKZ(tmp);
62  return s;
63 }
void Add_SKZ(const int skz_in)
Definition: student.cpp:29
void Del_SKZ(const int skz_in)
Definition: student.cpp:36
void Setname(const std::string &val)
Definition: student.cpp:27
Student()
Default constructor.
Definition: student.cpp:7
ostream & operator<<(ostream &s, const Student &rhs)
Definition: student.cpp:45
istream & operator>>(istream &s, Student &rhs)
Definition: student.cpp:56