friend std istream operator std istream os student ob ввод std cout En

 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
friend std::istream & operator >> (std::istream & os, student& ob){ // ввод
std::cout <<"Enter name:\n";
os >> ob.name;
ob.setName(ob.name);
std::cout <<"Enter second name:\n";
os >> ob.second_name;
ob.setSecondName(ob.second_name);
std::cout <<"Enter last name:\n";
os >> ob.last_name;
ob.setLastName(ob.last_name);
std::cout <<"Enter age:\n";
os >> ob.age;
ob.setAge(abs(ob.age));
std::cout <<"Enter number of record book:\n";
os >> ob.idStudent;
ob.setId(abs(ob.idStudent));
std::cout <<"Enter average:\n";
os >> ob.average;
ob.setAverage(abs(ob.average));
return os;
}
friend std::ostream & operator << (std::ostream & os, student& ob){ //вывод
os << "Name:";
os << ob.name;
os << "\nSecond name:";
os << ob.second_name;
os << "\nLast name:";
os << ob.last_name;
os << "\nAge:";
os << ob.age;
os << "\nNumber of record book:";
os << ob.idStudent;
os << "\nAverage:";
os << ob.average;
os << std::endl;
os << std::endl;
return os;
}
student& operator = (student &a){ / а это что?
name = a.name;
second_name = a.second_name;
last_name = a.last_name;
age = a.age;
idStudent = a.idStudent;
average = a.average;
return *this;
}
~student(){}
};