include iostream include stdio using namespace std struct student stri

 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
#include <iostream>
#include <stdio.h>
using namespace std;
struct student
{
string name;
string number;
string date;
};
class Group
{
private:
student * B;
int n;
public:
Group()
{
n = 0;
B = NULL;
}
Group(int _n)
{
n = _n;
B = (student*) new student[n];
for (int i=0; i<n; i++)
{
B[i].name = "";
B[i].number = "";
B[i].date = "00/00/00";
}
}
~Group()
{
if (n>0)
delete[] B;
}
int GetN() { return n; }
student& operator[](int index)
{
if ((index>=0)&&(index<n))
return B[index];
else
{
student BB;
BB.name = "";
BB.number = "";
BB.date = "00/00/00";
return BB;
}
}
};
int main()
{
Group BB(3);
BB[0].name = "Popov";
BB[0].number = "M23";
BB[0].date = "20/02/93";
BB[1].name = "Popova";
BB[1].number = "M28";
BB[1].date = "27/02/93";
BB[2].name = "Popovich";
BB[2].number = "M21";
BB[2].date = "20/02/95";
string title;
string num;
string d;
title = BB[1].name;
num = BB[2].number;
d = BB[0].date;
cout << title << endl;
cout << num<< endl;
cout<<d<<endl;
}