include iostream include string using namespace std class university p

 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include <iostream>
#include <string>
using namespace std;
class university
{
private:
string group;
string faculty;
int members;
public:
university();
university(string group, int members, string faculty);
~university();
void info();
void set();
};
void head();
int main()
{
int ans, c=0, members;
university u2("asd", 2, "aaa"), *u1=NULL, u3, u4;
head();
if(u1!=NULL) u1->info();
u2.info();
u3.info();
u4.info();
cout << endl;
u4.set();
u1=&u2;
head();
if(u1!=NULL) u1->info();
u2.info();
u3.info();
u4.info();
cout << endl;
//cout << "helll" << endl;
return 0;
}
university::university()
{
group="NULL";
members=0;
faculty="NULL";
}
university::university(string group, int members, string faculty)
{
this->group=group;
this->members=members;
this->faculty=faculty;
}
university::~university()
{
cout << "delete: " << group << endl;
}
void university::info()
{
cout.width(15);
cout << faculty;
cout.width(15);
cout << group;
cout.width(15);
cout << members << endl;
}
void university::set()
{
cout << endl << "Факультет: ";
cin >> this->faculty;
cout << "Группа: ";
cin >> this->group;
cout << "Количество: ";
cin >> this->members;
}
void head()
{
cout << endl;
cout.width(24);
cout << "Факультет" << flush;
cout.width(21);
cout << "Группа" << flush;
cout.width(25);
cout << "Количество" << flush;
cout << endl;
}