Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<conio.h>
- #include<stdlib.h>
- #include<stdio.h>
- #include<string.h>
- #include<iomanip>
- using namespace std;
- const int LNAME = 25;
- class Student {
- //name course gender
- public:
- string name; // ім’я
- int course; // вік
- bool gender; // рейтинг
- Student() {}; // конструктор без параметрів
- Student(string name, int course, bool gender) : name(name), course(course), gender(gender) // конструктор з параметрами
- {
- }
- void Get() {
- string gender1 = "";
- cout << "Iм'я: " << name << endl;
- cout << "Курс: " << course << endl;
- if (gender) {
- gender1 = "Чоловiча";
- }
- else {
- gender1 = "Жiноча";
- }
- cout << "Стать: " << gender1 << endl;
- }
- void Set() {
- cout << "Iм'я: ";
- cin >> name;
- cout << "Курс: ";
- cin >> course;
- cout << "Стать (ч-1; ж-0): ";
- cin >> gender;
- Student(name, course, gender);
- }
- };
- void GetArray(Student* student, int n) {
- string gender = "";
- for (size_t i = 0; i < n; i++)
- {
- cout << "Iм'я: " << student[i].name << endl;
- cout << "Курс: " << student[i].course << endl;
- if (student[i].gender) {
- gender = "Чоловiча";
- }
- else {
- gender = "Жiноча";
- }
- cout << "Стать: " << gender << endl;
- }
- }
- void SetArray(Student* student, int n) {
- for (int i = 0; i < n; i++)
- {
- cout << "Iм'я: ";
- cin >> student[i].name;
- cout << "Курс: ";
- cin >> student[i].course;
- cout << "Стать (ч-1; ж-0): ";
- cin >> student[i].gender;
- *student = Student(student->name, student->course, student->gender);
- }
- }
- void (Student::* pf)();
- void main()
- {
- setlocale(0, "");
- pf = &Student::Get;
- Student a("Богданов", 19, true), b =a ;
- (a.*pf)();
- b = a;
- b.Get();
- Student gruppa[3] = {
- Student("Сидор", 2, true),
- Student("Мартенюк", 1, true),
- Student("Наконечний", 4, false)
- };
- GetArray(gruppa, 3);
- Student* s = new Student[2];
- SetArray(s, 2);
- GetArray(s,2);
- }
Advertisement
Add Comment
Please, Sign In to add comment