First Class
Loading...
Searching...
No Matches
student.cpp
Go to the documentation of this file.
1#include "student.h"
2#include <algorithm> // erase
3#include <string>
4#include <vector>
5using namespace std;
6
7
8void Student::Add_SKZ(const int skz)
9{
10 vector<int>::iterator it;
11 it = find(_skz.begin(),_skz.end(), skz);
12 if ( it == _skz.end()) _skz.push_back(skz);
13}
14
15void Student::Del_SKZ(const int skz_in)
16{
17 //vector<int>::iterator it;
18 auto it = std::find(_skz.begin(),_skz.end(),skz_in);
19 if ( it != _skz.end() ) _skz.erase(it);
20 return;
21}
22
23
24ostream& operator<<(ostream& s, const Student& rhs)
25{
26 s << rhs._name << " : ";
27 //s << rhs.skz << endl;
28 for (unsigned int k=0; k<rhs._skz.size(); ++k)
29 {
30 s << rhs._skz.at(k) << " ";
31 }
32 return s;
33}
34
35istream& operator>>(istream& s, Student& rhs)
36{
37 s >> rhs._name;
38 int tmp;
39 s >> tmp;
40 rhs.Add_SKZ(tmp);
41 return s;
42}
void Add_SKZ(const int skz_in)
Definition student.cpp:8
void Del_SKZ(const int skz_in)
Definition student.cpp:15
istream & operator>>(istream &s, Student &rhs)
Definition student.cpp:35
ostream & operator<<(ostream &s, const Student &rhs)
Definition student.cpp:24