Student with set
student.h
Go to the documentation of this file.
1 #pragma once
2 #include <iostream> // ostream
3 #include <string>
4 #include <set>
5 #include <vector>
6 //using namespace std;
7 
10 class Student
11 {
12 public:
14  Student();
15 
22  Student(const std::string& name, const std::string& matrikel, const int studium);
23 
30  Student(const std::string & name, const std::string& matnr, const std::vector<int>& skz);
31 
32  // automatic generation of copy constructor and assignment operator by the compiler
33  // in C++11: the Assignment operator (and any other method) can be explicitely deleted via:
34  // Student& operator=(const Student& other) = delete;
35  Student(const Student &orig) = default;
36  Student( Student &&orig) = default;
37  // const member '_matr_nr' ==> kein Zuweisungsoperator moeglich!
38  Student& operator=(const Student &rhs) = delete;
39  Student& operator=( Student &&rhs) = delete;
40 
41 
43  //virtual
44  ~Student() { }
45 
49  std::string Getname() const
50  {
51  return _name;
52  }
53 
57  void Setname(const std::string &val) { _name = val; }
58 
63  std::string Getmatr_nr() const
64  {
65  return _matr_nr;
66  }
67 
73  void Add_SKZ(const int skz_in);
74 
79  void Del_SKZ(const int skz_in);
80 
85  int num_Studies() const
86  {
87  return static_cast<int>(_skz.size());
88  }
89 
94 // const std::vector<int>& Get_SKZ() const {return _skz;}
95  const std::vector<int> Get_SKZ() const;
96 
101  friend std::ostream& operator<<(std::ostream& s, const Student& rhs);
102 
108  friend std::istream& operator>>(std::istream& s, Student& rhs);
109 protected:
110 
111 private:
112  std::string _name;
113  // const member ==> kein Zuweisungsoperator moeglich!
114  const std::string _matr_nr;
115  std::set<int> _skz;
116 };
Student & operator=(Student &&rhs)=delete
void Add_SKZ(const int skz_in)
Definition: student.cpp:32
~Student()
Definition: student.h:44
const std::vector< int > Get_SKZ() const
Definition: student.cpp:42
Student & operator=(const Student &rhs)=delete
Student(Student &&orig)=default
Student(const std::string &name, const std::string &matrikel, const int studium)
friend std::ostream & operator<<(std::ostream &s, const Student &rhs)
Student(const Student &orig)=default
std::string Getname() const
Definition: student.h:49
Student(const std::string &name, const std::string &matnr, const std::vector< int > &skz)
int num_Studies() const
Definition: student.h:85
void Del_SKZ(const int skz_in)
Definition: student.cpp:37
void Setname(const std::string &val)
Definition: student.h:57
std::string Getmatr_nr() const
Definition: student.h:63
Student()
Definition: student.cpp:8
friend std::istream & operator>>(std::istream &s, Student &rhs)