Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- class Student
- {
- private:
- char surname[100];
- int age;
- double sr_ball;
- public:
- Student()
- {
- cout << "----------------------------------------" << endl;
- cout << "Вызван конструктор по умолчанию" << endl;
- strcpy_s(surname, "Неизвестно");
- age = 0;
- sr_ball = 0;
- cout << "----------------------------------------" << endl;
- }
- Student(const char* s_name)
- {
- cout << "----------------------------------------" << endl;
- cout << "Вызван конструктор копирования" << endl;
- strcpy_s(surname, s_name);
- age = 0;
- sr_ball = 0;
- cout << "----------------------------------------" << endl;
- }
- Student(const char* s_name, int a)
- {
- cout << "----------------------------------------" << endl;
- cout << "Вызван конструктор копирования" << endl;
- strcpy_s(surname, s_name);
- age = a;
- sr_ball = 0;
- cout << "----------------------------------------" << endl;
- }
- Student(const char* s_name, int a, double ball)
- {
- cout << "----------------------------------------" << endl;
- cout << "Вызван конструктор с параметрами" << endl;
- strcpy_s(surname, s_name);
- age = a;
- sr_ball = ball;
- cout << "----------------------------------------" << endl;
- }
- ~Student()
- {
- cout << "----------------------------------------" << endl;
- cout << "\nВызван деструктор" << endl;
- strcpy_s(surname, "");
- age = 0;
- sr_ball = 0;
- cout << "----------------------------------------" << endl;
- };
- void Input()
- {
- cout << "Введите фамилию студента: ";
- cin.getline(surname, 100);
- cout << "Введите возраст студента: ";
- cin >> age;
- cout << "Введите средний балл студента: ";
- cin >> sr_ball;
- };
- void Output()
- {
- cout << "----------------------------------------" << endl;
- cout << "Фамилия студента: " << surname << endl;
- cout << "Возраст студента:" << age << endl;
- cout << "Средний балл студента:" << sr_ball << endl;
- cout << "----------------------------------------" << endl;
- };
- };
- int main()
- {
- Student student1;
- Student student2("Левашов", 18, 4.5);
- Student student3("Парамонов", 18);
- student1.Output();
- student2.Output();
- student3.Output();
- Student student4;
- student4.Input();
- student4.Output();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement